On 15/02/17 15:40, Boris Petrov wrote:
Hello,

We are trying to run an Embedded Tomcat server (version 8.5.11) and have
it process some @WebServlet and @WebListener annotations. We are using
the "addContext" method of the Tomcat instance instead of the
"addWebapp" because we do not want the JSP servlet, the default web.xml
and none of the other things a "webapp" provides. However, after
spending some time reading the code and Googling, I'm reaching the
conclusion that one cannot use "addContext" and have Tomcat use the
annotated classes. Am I right?

No.

Why is that, if so?

addContext() is designed for entirely programmatic configuration of your web application.

And what do you suggest we do?

Take a look at the addWebapp() code and adapt it for your needs. The short version is you probably need to use addContext() and add a ContextConfig instance as a LifecycleListener. It does the annotatioin scanning. The bit you don't want is the DefaultWebXmlListener instance.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to