GitHub user bmeriaux opened a pull request: https://github.com/apache/tomcat-maven-plugin/pull/20
fix scanning of ServletContainerInitializer by tomcat > 7.0.5x ServletContainerInitializer not scanned in goal "run" I found that since tomcat v7.0.5x , because of a refactor on the scanning of the ServletContainerInitializer, it is broken in the tomcat maven plugin in the run goal. The bug is introduced by the new method of scanning of the new class "org.apache.catalina.startup.WebappServiceLoader" in tomcat core. The method "load" looks for lib jar path using servletContext.getResource() with the prefix "WEB-INb/lib", but in "run" goal, we do not have the dependencies in this folder, and because the method do not use the classloader, all lib jars are not scanned. The problematic code path is used if the "servletContext.getAttribute(ServletContext.ORDERED_LIBS);" return a list. But if we clear this list, the load method will scan every jar in the classpath. To fix the problem we have three solutions: clear the servletContext attribute ServletContext.ORDERED_LIBS, or get the lib loaded in dependencies accessible by servletContext.getResource("WEB-INb/lib" + jarName), or put the dependencies in the parent classloader The first solution can be easily implemented by extending the ContextConfig class to override the processServletContainerInitializers method in the following way. protected void processServletContainerInitializers(ServletContext servletContext) { List saveOrderedLib = (List) servletContext.getAttribute(ServletContext.ORDERED_LIBS); servletContext.setAttribute(ServletContext.ORDERED_LIBS, null); super.processServletContainerInitializers(servletContext); servletContext.setAttribute(ServletContext.ORDERED_LIBS, saveOrderedLib); } and using this custom ContextConfig class in the ExtendedTomcat class. You can merge this pull request into a Git repository by running: $ git pull https://github.com/bmeriaux/tomcat-maven-plugin fix_servletContainerInitializer_scan Alternatively you can review and apply these changes as the patch at: https://github.com/apache/tomcat-maven-plugin/pull/20.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #20 ---- commit 162c35ec0ec929e690dfbea1e4e67d7f648cd591 Author: Benoit Meriaux <bmeri...@octo.com> Date: 2015-10-13T19:43:06Z fix scanning of ServletContainerInitializer by tomcat > 7.0.5x in "run" goal ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org