On 02/10/17 07:23, Brian Toal wrote: > I want to decouple my solution from web.xml completely, so the goal is to > have the container to scan all jars on the classpath and look for Servlet > 3.0 annotations and do the necessary (register servlet context listeners, > filters, servlets, etc). In the code below, the container starts, but none > of the corresponding annotations are processed. I have various jars on the > classpath that contain implementations of the Servlet 3.0 annotation. I'm > most certain I'm missing the configuration that is required to get Tomcat > to do the scanning and processing, but i'm not aware of what that would > be. What code do I need to add to get the container to scan all jars on > the classpath for Servlet 3.0 annotations and register the various found > artifacts with the container?
If you use addContext(), you have to do all of that yourself. Take a look at the difference in the Tomcat class between addContext() and addWebapp(). You probably also want to take a look at org.apache.catalina.startup.ContextConfig Mark > > Here's a snippet of what my code looks like so far. See [1] for full > source. > > > public void start(ApplicationContext acac) { > try { > Tomcat tomcat = new Tomcat(); > tomcat.setPort(8080); > // init http connector > tomcat.getConnector(); > File base = new File("."); > Context ctx = tomcat.addContext("", base.getAbsolutePath()); > ServletContext servletContext = ctx.getServletContext(); > tomcat.start(); > tomcat.getServer().await(); > } catch (LifecycleException e) { > throw new RuntimeException("Unable to launch tomcat ", e); > } > } [1] - https://github.com/toaler/container/blob/master/ > container-webapp-tomcat/src/main/java/container/webapp/ > tomcat/TomcatWebContainer.java > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org