On 10/05/17 10:26, Michael Heinen wrote: > Am 10.05.2017 um 00:40 schrieb Mark Thomas: >> On 09/05/17 15:25, Michael Heinen wrote: >>> Hi all, >>> >>> I am currently mirgating an application from Tomcat 7.0.73 to 8.0.43. >>> On development platforms we use an embedded tomcat. >>> On of the jars on the classpath contains a web-fragment.xml in it's >>> META-INF folder. >>> This jar file is NOT located within the webApp but simply on the >>> classpath. >>> With Tomcat 7.0.73 the web-fragment is processed and the defined filter >>> is instantiated. >>> With Tomcat 8.0.43 the web-fragment is not processed at all. >>> >>> Some lines of code: >>> >>> final StandardContext ctx = ... >>> ctx.setXmlBlockExternal(false); >>> >>> final StandardJarScanner jarScanner = new StandardJarScanner(); >>> jarScanner.setScanAllDirectories(true); >>> jarScanner.setScanAllFiles(true); >>> jarScanner.setScanBootstrapClassPath(true); >>> jarScanner.setScanClassPath(true); >>> jarScanner.setScanManifest(false); >>> ctx.setJarScanner(jarScanner); >>> >>> Should this work with Tomcat 8 or is my expectation wrong? >> It should work. I'd recommend putting a break-point in >> StandardJarScanner and stepping through the Tomcat code to see what is >> going wrong. >> >> Mark > > Thanks Mark > Here are the results from debugging: > > 1) Tomcat 8.0.43: > The boolean parameter "isWebapp" is false in this case and therefore the > web-fragment is not processed at all. > See > org.apache.tomcat.util.descriptor.web.FragmentJarScannerCallback.scan(Jar, > String, boolean) > > // Only web application JARs are checked for web-fragment.xml > // files. > // web-fragment.xml files don't need to be parsed if they are never > // going to be used. > if (isWebapp && parseRequired) { > is = jar.getInputStream(FRAGMENT_LOCATION); > } > > 2) Tomcat 7.0.73: > There is no check for webApps. The member "parseRequired" is true and > therefore the fragment is loaded. > See > org.apache.catalina.startup.ContextConfig.FragmentJarScannerCallback.scan(JarURLConnection) > > > if (parseRequired || context.getXmlValidation()) { > is = jar.getInputStream(FRAGMENT_LOCATION); > }
Thanks for digging in to that. That certainly explains the different behaviours. > Should I open a bug? Maybe. There might be a (spec related) reason for that. E.g. Something that was tightened up / clarified in Servlet 3.1 that wasn't back-ported to Tomcat 7 in case users were relying on the functionality. The next thing to check is the svn history for those files. https://svn.apache.org/viewvc/tomcat/ and the annotate (a.k.a blame) view is useful for that. The key is likely to be the commit that added the isWebapp test. Mark --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org