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

The FileNotFoundException thrown from StandardJarScanner when using layered JARs isn't very helpful #23139

Closed
maxxedev opened this issue Aug 30, 2020 · 5 comments
Labels
status: duplicate A duplicate of another issue

Comments

@maxxedev
Copy link

Given a spring-boot application with jsp and layered jar, starting it according to blog post instructions produces FileNotFoundException from Tomcat's StandardJarScanner:

2020-08-30 15:07:26.578  WARN 16958 --- [           main] o.a.tomcat.util.scan.StandardJarScanner  :
Failed to scan [file:/path/to/spring-petclinic/target/bug-report/HikariCP-3.4.5.jar] from classloader hierarchy
java.io.FileNotFoundException: /path/to/spring-petclinic/target/bug-report/HikariCP-3.4.5.jar (No such file or directory)
        at java.util.zip.ZipFile.open(Native Method) ~[na:1.8.0_242]
        at java.util.zip.ZipFile.<init>(ZipFile.java:230) ~[na:1.8.0_242]
        at java.util.zip.ZipFile.<init>(ZipFile.java:160) ~[na:1.8.0_242]
        at java.util.jar.JarFile.<init>(JarFile.java:166) ~[na:1.8.0_242]
        at java.util.jar.JarFile.<init>(JarFile.java:130) ~[na:1.8.0_242]
        at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:221) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
        at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:65) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
        at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:49) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
        at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:383) [tomcat-embed-core-9.0.37.jar:9.0.37]
        at org.apache.tomcat.util.scan.StandardJarScanner.processURLs(StandardJarScanner.java:318) [tomcat-embed-core-9.0.37.jar:9.0.37]
        at org.apache.tomcat.util.scan.StandardJarScanner.doScanClassPath(StandardJarScanner.java:270) [tomcat-embed-core-9.0.37.jar:9.0.37]

Tested under: spring-petclinic with spring-boot 2.3.3 release.
You can find a reproducible example here. Run test.sh script

The problem appears to be that JarLauncher adds entries from classpath.idx:

file:/path/to/spring-petclinic/target/bug-report/BOOT-INF/classes/
file:/path/to/spring-petclinic/target/bug-report/BOOT-INF/lib/HdrHistogram-2.1.12.jar
file:/path/to/spring-petclinic/target/bug-report/BOOT-INF/lib/HikariCP-3.4.5.jar
[...]
file:/path/to/spring-petclinic/target/bug-report/HdrHistogram-2.1.12.jar
file:/path/to/spring-petclinic/target/bug-report/HikariCP-3.4.5.jar
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 30, 2020
@philwebb
Copy link
Member

JSPs cannot be used with JAR files and unfortunately layered wars are not yet supported (issue #22195 is tracking that request).

The current error message isn't very helpful, so I'd like to dig into it a little more to see if we can't provide something better.

@philwebb philwebb added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 31, 2020
@philwebb philwebb added this to the 2.3.x milestone Aug 31, 2020
@philwebb philwebb changed the title layered jar startup shows FileNotFoundException from StandardJarScanner The FileNotFoundException thrown from StandardJarScanner when using layered JARs isn't very helpful Aug 31, 2020
@aprantl
Copy link

aprantl commented Sep 10, 2020

I am having this issue too since updating to 2.3.3. It actually does not only affect layered JARs. I get the same warning messages in the log once the (layered or non-layered) JAR is exploded and executed with java org.springframework.boot.loader.JarLauncher --cp my-application-root. According to the message BOOT-INF\lib is missing in the URL path lookup. The warn If I execute the JAR directly, there are no warnings.

JSPs weren't support by default - agreed. But there have been rather easy workarounds as described here. It would be unfortunate if the new LaunchedURLClassLoader, the handling of the classpath in org.springframework.boot.loader.Launcher, or something else now breaks with this workaround.

@scottfrederick
Copy link
Contributor

The root cause of this issue was identified by @wilkinsona in a separate issue. The output from the provided sample app shows the same duplicate entries for each jar in the classloader, with a valid jar entry in BOOT-INF/lib/ and an invalid entry pointing to the local file system.

@scottfrederick
Copy link
Contributor

Closing this as a duplicate of #24192 since the other issue identifies the root cause.

@scottfrederick scottfrederick added status: duplicate A duplicate of another issue and removed type: bug A general bug labels Jan 6, 2021
@scottfrederick scottfrederick removed this from the 2.3.x milestone Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

5 participants