Bug 61503

Summary: JarWarResourceSet finds META-INF/ jar entries that do not exist leading to FileNotFoundException
Product: Tomcat 8 Reporter: Andy Wilkinson <awilkinson>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 8.5.14   
Target Milestone: ----   
Hardware: PC   
OS: All   

Description Andy Wilkinson 2017-09-08 11:49:58 UTC
I believe that the fix for https://bz.apache.org/bugzilla/show_bug.cgi?id=60940 has introduced a regression. When a JSF-based application is run from a war archive (either using unpackWARs=false or Tomcat embedded in an executable war with Spring Boot) the application will fail to start if it depends on H2. The failure occurs because H2's jar file does not contain a META-INF/ directory entry; it only contains entries for the two files beneath the directory. This leads to a FileNotFoundException when calling getJarFile() on the connection to the URL for the resource:

Caused by: java.io.FileNotFoundException: JAR entry META-INF/ not found in /var/folders/zq/v6xkr2696kv05jbf3bddt9680000gn/T/jar_cache4058734571815148022.tmp
	at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:142) ~[na:1.8.0_141]
	at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:89) ~[na:1.8.0_141]
	at com.sun.faces.facelets.util.Classpath.search(Classpath.java:145) ~[jsf-impl-2.2.7.jar!/:2.2.7]
	at com.sun.faces.facelets.util.Classpath.search(Classpath.java:109) ~[jsf-impl-2.2.7.jar!/:2.2.7]
	at com.sun.faces.config.configprovider.MetaInfFacesConfigResourceProvider.loadURLs(MetaInfFacesConfigResourceProvider.java:164) ~[jsf-impl-2.2.7.jar!/:2.2.7]
	at com.sun.faces.config.configprovider.MetaInfFacesConfigResourceProvider.getResources(MetaInfFacesConfigResourceProvider.java:108) ~[jsf-impl-2.2.7.jar!/:2.2.7]
	... 15 common frames omitted

A sample application that reproduces the problem is available in this Spring Boot issue: https://github.com/spring-projects/spring-boot/issues/10232
Comment 1 Mark Thomas 2017-09-08 16:52:22 UTC
This would be easier to investigate with a WAR I could deploy in a standard Tomcat instance but when I try that with the provided sample it appears no initialization occurs. I haven't (yet) dug into why.
Comment 2 Andy Wilkinson 2017-09-08 16:55:35 UTC
I think I understand the problem well enough to create a much simpler sample that reproduces the problem. Let me know if that would be useful and I'll see what I can manage.
Comment 3 Mark Thomas 2017-09-08 18:40:25 UTC
Thanks. Let me get back to you on that offer.
Comment 4 Mark Thomas 2017-09-12 19:47:43 UTC
Fixed in:
- trunk for 9.0.0.M27 onwards
- 8.5.x for 8.5.21 onwards
- 8.0.x for 8.0.47 onwards