Re: Configuring embedded Tomcat with @WebServlet annotations
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 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
Re: Configuring embedded Tomcat with @WebServlet annotations
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). Il sab 9 mar 2019, 20:45 Mark Thomas 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 > >
Re: Configuring embedded Tomcat with @WebServlet annotations
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
Re: Configuring embedded Tomcat with @WebServlet annotations
On 09/03/2019 15:01, Raffaele Sgarro wrote: > I wonder why you think I didn't read the fucking manual before posting my > question here. While the reply to your question wasn't helpful, that does not justify the tone of your response. I'd like to remind everyone of the code of conduct: https://www.apache.org/foundation/policies/conduct.html I'd also recommend everyone (re-)reads this from time to time: http://community.apache.org/contributors/etiquette Mark > > You'd be surprised to know that I'm studying this thing since a couple of > days and my conclusion is that it's something Tomcat can't do and I'll have > to use something like Spring to achieve it. > > So no, it's not documented in the website. > > Il sab 9 mar 2019, 15:15 Phumelela Mdluli ha scritto: > >> Hey, >> >> Try reading this, I think you will be fine: >> >> http://tomcat.apache.org/tomcat-9.0-doc/index.html >> >> No one can do it for you. >> >> Regards, >> >> Phumelela >> >> On Fri, Mar 8, 2019 at 7:47 PM 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? >>> >>> Thanks, >>> Raffaele >> >> >> >> -- >> Yours Sincerely, >> >> Phumelela Mdluli >> Lake Forest College '15 >> Waterford Kamhlaba '10 '08 >> >> - >> 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
Re: Configuring embedded Tomcat with @WebServlet annotations
I wonder why you think I didn't read the fucking manual before posting my question here. You'd be surprised to know that I'm studying this thing since a couple of days and my conclusion is that it's something Tomcat can't do and I'll have to use something like Spring to achieve it. So no, it's not documented in the website. Il sab 9 mar 2019, 15:15 Phumelela Mdluli ha scritto: > Hey, > > Try reading this, I think you will be fine: > > http://tomcat.apache.org/tomcat-9.0-doc/index.html > > No one can do it for you. > > Regards, > > Phumelela > > On Fri, Mar 8, 2019 at 7:47 PM 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? > > > > Thanks, > > Raffaele > > > > -- > Yours Sincerely, > > Phumelela Mdluli > Lake Forest College '15 > Waterford Kamhlaba '10 '08 > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >
Re: Configuring embedded Tomcat with @WebServlet annotations
Hey, Try reading this, I think you will be fine: http://tomcat.apache.org/tomcat-9.0-doc/index.html No one can do it for you. Regards, Phumelela On Fri, Mar 8, 2019 at 7:47 PM 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? > > Thanks, > Raffaele -- Yours Sincerely, Phumelela Mdluli Lake Forest College '15 Waterford Kamhlaba '10 '08 - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Configuring embedded Tomcat with @WebServlet annotations
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? Thanks, Raffaele