jvrubel opened a new pull request, #26039:
URL: https://github.com/apache/camel/pull/26039
Fix LauncherHelper to handle Spring Boot 3.x jar:nested: URL scheme
Problem
The productized camel-launcher-4.22.0.redhat-00010 is packaged as a Spring
Boot 3.x executable fat JAR (Main-Class:
org.springframework.boot.loader.launch.JarLauncher). Spring
Boot 3.x uses a jar:nested: URL scheme for code source locations of
classes loaded from nested library JARs:
`
jar:nested:/path/to/camel-launcher-4.22.0.redhat-00010.jar/!BOOT-INF/lib/camel-jbang-core-4.22.0.redhat-00003.jar!/`
`LauncherHelper.getLauncherJarPath()` only handled jar:file: (Spring Boot
2.x / Maven Shade) and file: URL schemes. When it received a jar:nested: URL,
it returned null.
This caused `isRunningFromLauncher()` to return false, so
`getCamelCommand()` fell back to ["camel"] — a command that does not exist when
running from the fat JAR. Any operation
that spawned a background process (e.g. camel run <file> --background)
failed with:
`java.io.IOException: Cannot run program "camel": error=2, No such file or
directory`
This produced 52 test failures across all test cases exercising
--background mode in the camel/launcher-it CI job.
Fix
Add a jar:nested: case to `getLauncherJarPath()`, before the existing
jar:file: handler. The outer JAR path is extracted by splitting on /! (the
separator between the outer JAR
and the nested path):
`if (urlStr.startsWith("jar:nested:")) {
String path = urlStr.substring("jar:nested:".length());
int idx = path.indexOf("/!");
if (idx > 0) {
return URLDecoder.decode(path.substring(0, idx),
StandardCharsets.UTF_8);
}
}`
For the URL above, this correctly extracts
/path/to/camel-launcher-4.22.0.redhat-00010.jar, causing `getCamelCommand()` to
return ["java", "-jar",
"/path/to/camel-launcher-4.22.0.redhat-00010.jar"].
Magic number offsets in the existing jar:file: and file: branches were
also replaced with named-length constants for readability.
Verification
Replicated the failure locally by running `java -jar
camel-launcher-4.22.0.redhat-00010.jar run route.java --background` with camel
removed from PATH. Confirmed the identical
Cannot run program "camel" error. Applied the fix and verified
`getLauncherJarPath()` returns the correct outer JAR path from the jar:nested:
URL.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]