You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2022/03/06 08:25:00 UTC

[jira] [Resolved] (CAMEL-17738) camel-spring-boot - Cannot load resources from nested jar inside spring boot fat jar

     [ https://issues.apache.org/jira/browse/CAMEL-17738?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-17738.
---------------------------------
    Resolution: Fixed

> camel-spring-boot - Cannot load resources from nested jar inside spring boot fat jar
> ------------------------------------------------------------------------------------
>
>                 Key: CAMEL-17738
>                 URL: https://issues.apache.org/jira/browse/CAMEL-17738
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-spring-boot
>    Affects Versions: 3.14.1
>            Reporter: Brad Harvey
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 3.14.3, 3.16.0
>
>
> In camel 3.14.1 / spring boot 2.6.3 XML routes cannot be loaded from a nested jar.  I suspect earlier versions of both are also affected, but Camel 3.4.x + Spring Boot 2.3.x did load them ok.  
> In this code from FatJarPackageScanResourceResolver, "name" is the nested jar name - it will end in .jar.  To traverse into the spring boot jar it would need to go into the second branch - the  "else if"  - but it will always go into the first branch because it is a not a directory and the name does not end in .class.  
>  
> {code:java}
>                 String name = entry.getName();
>                 name = name.trim();
>                 if (!entry.isDirectory() && !name.endsWith(".class")) {
>                     name = cleanupSpringBootClassName(name);
>                     // name is FQN so it must start with package name
>                     if (name.startsWith(packageName)) {
>                         entries.add(name);
>                     }
>                 } else if (inspectNestedJars && !entry.isDirectory() && isSpringBootNestedJar(name)) {
>                     String nestedUrl = urlPath + "!/" + name;
>                     log.trace("Inspecting nested jar: {}", nestedUrl);
>                     List<String> nestedEntries = doLoadImplementationsInJar(packageName, jarStream, nestedUrl, false, false);
>                     entries.addAll(nestedEntries);
>                 }
> {code}
>  
> I think this code was copied from the class resolver and name.endsWith(".class") changed to !name.endswith(".class") but it doesn't do what is needed.
>  
> Solution may be to swap the order of the if checks so that nested jars are found & traversed first.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)