tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Toal <>
Subject Setting up Embedded Tomcat to honor Servlet 3.0 Annotations
Date Mon, 02 Oct 2017 06:23:03 GMT
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?

Here's a snippet of what my code looks like so far.  See [1] for full

public void start(ApplicationContext acac) {
try {
Tomcat tomcat = new Tomcat();
// init http connector
File base = new File(".");
Context ctx = tomcat.addContext("", base.getAbsolutePath());
ServletContext servletContext = ctx.getServletContext();
} catch (LifecycleException e) {
throw new RuntimeException("Unable to launch tomcat ", e);
} [1] -

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message