Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic execution of js route failing #5678

Closed
squakez opened this issue Jan 25, 2024 · 8 comments
Closed

Dynamic execution of js route failing #5678

squakez opened this issue Jan 25, 2024 · 8 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@squakez
Copy link
Contributor

squakez commented Jan 25, 2024

Bug description

I'm trying to run a polyglot application which is composed by multiple routes in multiple languages. I found out that when we run js applications, if we provide the classpath list of dependencies, the execution fails with the following error:

java -cp target/quarkus-app/lib/main/*:target/quarkus-app/quarkus-run.jar io.quarkus.bootstrap.runner.QuarkusEntryPoint
...
2024-01-25 11:38:57,034 INFO  [org.apa.cam.mai.BaseMainSupport] (main)     [MicroProfilePropertiesSource] camel.main.routesIncludePattern=file:/tmp/test/**
2024-01-25 11:38:57,035 INFO  [org.apa.cam.mai.BaseMainSupport] (main)     [MicroProfilePropertiesSource] camel.main.sourceLocationEnabled=true
2024-01-25 11:38:57,261 ERROR [org.apa.cam.qua.mai.CamelMainRuntime] (main) Failed to start application: org.graalvm.polyglot.PolyglotException: java.lang.IllegalStateException: Duplicate language id regex. First language [Language class com.oracle.truffle.regex.RegexLanguage, Loaded from file:/home/squake/Desktop/jbang/ceq-java/target/quarkus-app/lib/main/org.graalvm.regex.regex-23.0.1.jar]. Second language [Language class com.oracle.truffle.regex.RegexLanguage, Loaded from file:/home/squake/Desktop/jbang/ceq-java/target/quarkus-app/lib/main/org.graalvm.regex.regex-23.0.1.jar].
	at com.oracle.truffle.polyglot.LanguageCache.createLanguages(LanguageCache.java:259)
...

It seems there was a similar issue in Quarkus core: quarkusio/quarkus#27090 - I wonder if we need to do something in Camel Quarkus as well to incorporate that change.

Mind that the same would work flawlessly if run via:

java -jar target/quarkus-app/quarkus-run.jar

However I need to specify the list of dependencies in order to make it works Java applications which it seems to be required by joor.

@squakez squakez added the bug Something isn't working label Jan 25, 2024
@jamesnetherton
Copy link
Contributor

org.graalvm.regex:regex probably needs to be configured as a runnerParentFirstArtifact.

seems to be required by joor

Maybe that's something that needs digging into a bit deeper.

When I added the initial fast-jar support in camel-k, I couldn't figure out how to make joor work without manually adding everything to the classpath. It'd be so much simpler if you could just execute the runnable JAR as per normal.

@jamesnetherton
Copy link
Contributor

You might be able to work around it if you set a build time property like:

quarkus.class-loading.parent-first-artifacts=org.graalvm.regex:regex

@lburgazzoli
Copy link
Contributor

When I added the initial fast-jar support in camel-k, I couldn't figure out how to make joor work without manually adding everything to the classpath. It'd be so much simpler if you could just execute the runnable JAR as per normal.

I think relying on the fast-jar would be the right think imho, we can tune the camel-k image discovery to require a 100% compatible one and re-visit image layering

@squakez
Copy link
Contributor Author

squakez commented Jan 25, 2024

When I added the initial fast-jar support in camel-k, I couldn't figure out how to make joor work without manually adding everything to the classpath. It'd be so much simpler if you could just execute the runnable JAR as per normal.

Yeah, I was trying to revert that but I was unsuccessful as well. It would be much cleaner, of course. In any case I manage to make it work with -cp target/quarkus-app/lib/main/* style which would be a first progress. However, now the problem is on the js DSL. I'm going to see if the workaround is good and report here. Thanks @jamesnetherton

@squakez
Copy link
Contributor Author

squakez commented Jan 26, 2024

FYI, the workaround is working.

@jamesnetherton
Copy link
Contributor

Assuming my change gets backported, this should get fixed permanently in 3.8.x. Otherwise it'll be in 3.9.x.

@squakez
Copy link
Contributor Author

squakez commented Jan 31, 2024

Assuming my change gets backported, this should get fixed permanently in 3.8.x. Otherwise it'll be in 3.9.x.

Great, thanks a lot @jamesnetherton

@jamesnetherton jamesnetherton self-assigned this Feb 14, 2024
@jamesnetherton jamesnetherton added this to the 3.8.0 milestone Feb 14, 2024
@jamesnetherton
Copy link
Contributor

Quarkus fix is present in 3.8.0.CR1 (and also 3.7.3 when it gets released).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants