tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: Configuring embedded Tomcat with @WebServlet annotations
Date Sat, 09 Mar 2019 19:45:09 GMT
On 08/03/2019 17:47, Raffaele Sgarro wrote:
> Hello all! How is one supposed to configure Tomcat (I'm on 9.x) to scan a
> given package looking for @WebServlet servlets?
> 
> I cannot find any API and relevant examples in the Tomcat source.
> 
> More insight: my app is currently packaged as a WAR and deployed to a
> running Tomcat instance. I want to build a fat JAR and starting Tomcat in
> my main() - but then I do not have any WAR/JAR because all classes are on
> classpath. Is there some utility in Tomcat? Is there any external library
> commonly used for this?

Scanning for annotations (and various other bits and pieces) is
controlled by the JarScanner component.

http://tomcat.apache.org/tomcat-9.0-doc/config/jar-scanner.html

You might need to set scanBootstrapClassPath="true" depending on exactly
how your far JAR is packaged / structured.

Another option is to use logEffectiveWebXml on the Context to create the
equivalent web.xml and then use that.

Mark

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


Mime
View raw message