[
https://issues.apache.org/jira/browse/CAMEL-23370?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-23370:
--------------------------------
Fix Version/s: 4.21.0
> camel.main.routes-include-pattern with classpath:**/*.xml fails in Spring
> Boot fat JAR (works in IDE, regression since 4.11.0)
> ------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-23370
> URL: https://issues.apache.org/jira/browse/CAMEL-23370
> Project: Camel
> Issue Type: Bug
> Components: camel-spring-boot
> Affects Versions: 4.20.0
> Reporter: Vilmos Nagy
> Priority: Minor
> Fix For: 4.21.0
>
>
> *Description:*
> After upgrading to a version including Apache Camel change from CAMEL-21944,
> route discovery using wildcard patterns no longer works correctly when
> running as a Spring Boot fat JAR.
> Previously working configurations using recursive classpath scanning
> ({{{}*{*}/{*}.xml{}}}) now fail at runtime with {{{}java -jar{}}}, while
> still working when executed from IDE (exploded classpath).
> {*}This worked correctly in Camel 4.11.0, including when running via {{{}java
> -jar{}}}, and appears to be a regression in newer versions.{*}{*}{{*}}
> A minimal reproducer is available here:
> [https://github.com/vilmosnagy/camel-spring-boot-examples/tree/vilmos/poc-broken-routes-include-pattern]
> (GitHub fork of the sample project demonstrating the issue).
> ----
> *Environment:*
> * Camel version: 4.21.0-SNAPSHOT (regression compared to 4.11.0)
> * Spring Boot: 4.0.6
> * Packaging: Spring Boot fat JAR ({{{}java -jar{}}})
> * OS: Linux (reproducible)
> ----
> *Configuration:*
> {{{}application.properties{}}}:
>
> {code:java}
> camel.main.routes-include-pattern=classpath:camel/*/.xml{code}
> Project structure:
>
>
> {code:java}
> src/main/resources/
> ├── application.properties
> └── camel
> └── test-route
> └── route.xml{code}
>
> ----
> *Steps to reproduce:*
> # Create a Spring Boot + Camel application
> # Place XML routes under nested directories (e.g.
> {{{}camel/test-route/route.xml{}}})
> # Use:
> {code:java}
> camel.main.routes-include-pattern=classpath:camel/*/.xml{code}
> # Build fat JAR:
> {code:java}
> mvn clean package{code}
>
> # Run:
> {code:java}
> java -jar target/app.jar{code}
>
> ----
> *Expected behavior:*
> All XML routes under {{camel/**}} are discovered and loaded, consistent with:
> * Running from IDE
> * *Running via {{java -jar}} on Camel 4.11.0*
> ----
> *Actual behavior:*
> Application fails during startup with:
> java.io.IOException: No input stream for:
> nested:.../app.jar/!BOOT-INF/classes/!/camel/route.xml
> Stacktrace indicates failure in resource loading:
> DefaultSourceLoader.loadResource
> RoutesConfigurer.addDiscoveredRoutes
> *Important observations:*
> * Running from IDE (exploded classpath) → *works*
> * Running fat JAR ({{{}java -jar{}}}) → *fails*
> * Camel 4.11.0:
> ** IDE → *works*
> ** {{java -jar}} → *works*
> * Newer versions (incl. 4.21.0-SNAPSHOT):
> ** IDE → *works*
> ** {{java -jar}} → *fails*
> * Narrowing pattern to a single directory works:
> camel.main.routes-include-pattern=classpath:camel/test-route/*.xml
>
> but this is not viable for multiple subdirectories.
> ----
> *Suspected cause:*
> The issue appears related to changes introduced in CAMEL-21944, specifically
> replacing:
> final ResourceLoader loader =
> PluginHelper.getResourceLoader(getCamelContext());
> resources.add(loader.resolveResource(name));
> with:
> Resource resource = new PackageScanJarResource("jar", url, name);
> resources.add(resource);
> This seems to break handling of nested resources inside Spring Boot fat JARs
> ({{{}BOOT-INF/classes{}}}), particularly when using recursive glob patterns.
> ----
> *Additional notes:*
> * The failing path includes {{nested:}} URLs, suggesting incompatibility
> with Spring Boot’s nested JAR classloader.
> * Clear regression from Camel 4.11.0 behavior.
> ----
> *Workaround:*
> camel.main.routes-include-pattern=classpath:camel/test-route/*.xml
> (does not scale for multiple directories)
> ----
> *Contribution:*
> If this is confirmed to be a bug, we’re happy to help investigate further or
> contribute a fix.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)