Tomcat/TomEE: Failed to scan /not/existing/lib.jar
A user got a weird issue on TomEE list lately and thought it can help others to understand what it is and how to solve it so here is his story.
All started with warning at startup looking like:
AVERTISSEMENT - Failed to scan [file:/C:/Users/romain/.babun/cygwin/tmp/apache-tomee-plus-7.0.1/lib/lib/policy.jar] from classloader hierarchy
java.io.FileNotFoundException: C:\Users\romain\.babun\cygwin\tmp\apache-tomee-plus-7.0.1\lib\lib\policy.jar (File not found)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:219)
at java.util.zip.ZipFile.<init>(ZipFile.java:149)
at java.util.jar.JarFile.<init>(JarFile.java:166)
at java.util.jar.JarFile.<init>(JarFile.java:130)
at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:60)
at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:43)
at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:326)
at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:276)
at org.apache.tomee.loader.TomEEJarScanner.scan(TomEEJarScanner.java:61)
at org.apache.catalina.startup.ContextConfig.processJarsForWebFragments(ContextConfig.java:1887)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1122)
at org.apache.catalina.startup.OpenEJBContextConfig.webConfig(OpenEJBContextConfig.java:402)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:771)
at org.apache.catalina.startup.OpenEJBContextConfig.configureStart(OpenEJBContextConfig.java:123)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:298)
…..
Mainly file a not found but checking the configuration all looks fine, common.loader is well set up, library is in $CATALINA_BASE/lib so how a not existing file can be missing?
After investigation it was due to an additional library with a META-INF/MANIFEST.MF containing a relative Class-Path which was leading to inspect these not existing URLs. Concretely a jar in lib/ was containing a Class-Path entry to lib/policy.jar which was resolved to lib/lib/policy.jar which was obviously missing.
Nothing that important since it is just a warning but never good to keep them in the logs and you never know if the warning can become an error later so let’s fix it.
How to find the jar?
To find the jar the easiest is likely to use a small bash script (executed from $CATALINA_HOME or $CATALINA_BASE):
for i in lib/*.jar; do
r=$(unzip -p $i META-INF/MANIFEST.MF | grep Class-Path);
if [ $? -eq 0 ]; then
echo $i && echo $r && echo;
fi;
done
It will print something like:
lib/corrupted.jar
Class-Path: lib/notthere.jar lib/missing.jar
lib/openejb-core-7.0.1.jar
Class-Path: openejb-loader-7.0.1.jar openejb-client-7.0.1.jar
OpenEJB-core library is excluded from scanning so it is not a big deal and it can be ignored but corrupted.jar not being known by TomEE/Tomcat is scanned and leads to this error.
The easiest to solve it is to add it to exclusions. For that two solutions:
-
conf/catalina.properties: add it to tomcat.util.scan.StandardJarScanFilter.jarsToSkip list
-
conf/exclusions.list: add it to the list if you already use that or create the file and add it under the line ‘default-list”
And that’s it, restart and the exception/WARNING should be gone :).
From the same author:
In the same category:

