On 09/03/2019 20:00, Raffaele Sgarro wrote: > I apologize for the tone. > > Already tried various StandardJarScanner options, but the root problem is > that nothing works while developing because classes from source Java files > are not packaged at all and are simply put on the classpath by the IDE (and > I do not want to add the directory used by the compiler of the IDE to the > path read by the scanner).
That is going to be tricky. The JarScanner only finds "roots" of class collections. JAR files, directories of classes etc. It is the JarScannerCallback that processes them and there isn't any easy way limit what the callbacks scan - e.g. to a given Java package. Even the non-easy ways involve some fairly invasive code changes to Tomcat. We did fix a bug for 9.0./15 onwards that added this method: Tomcat.addWebapp(Strign URL) The URL can point to a WAR within the JAR. Tomcat then extracts the WAR to the local file system and runs it from there. Not exactly what you were looking for but I mention it in case it is good enough. Mark > > Il sab 9 mar 2019, 20:45 Mark Thomas <ma...@apache.org> ha scritto: > >> 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-unsubscr...@tomcat.apache.org >> For additional commands, e-mail: users-h...@tomcat.apache.org >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org