Summary: | No SCI scan in embedded Tomcat | ||
---|---|---|---|
Product: | Tomcat 8 | Reporter: | Dave Syer <david_syer> |
Component: | Catalina | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 8.0.x-trunk | ||
Target Milestone: | ---- | ||
Hardware: | PC | ||
OS: | Linux | ||
Bug Depends on: | 55287 | ||
Bug Blocks: |
Description
Dave Syer
2013-07-26 15:37:46 UTC
I played around with the Tomcat embedded server a bit more and found that it actually is relatively easy (if obscure) to switch on SCI: ContextConfig contextConfig = new ContextConfig(); context.addLifecycleListener(contextConfig); The biggest problem is that the classpath scanner only scans certain well-known locations (/WEB-INF/lib/*.jar, /WEB-INF/classes I am guessing) so it doesn't pick up anything else by default that happens to be on the classpath but in a different location (e.g. if you launch with java -jar, or from inside an IDE). I think that's a bigger problem than the obscure API for setting it up. There are some mentions in comments about /WEB-INF/classes being bound to multiple locations to help Eclipse tooling, so there is some precedence for the required generalization, but again no obvious API for adding bindings. I'm working on a fix for 55287 and as part of that I have separated the SCI discovery from ContextConfig. That would allow an embedder to perform their own scan for SCIs based on just the ServletContext obtained from the Context they are initializing. I committed the change to decouple SCI loading in http://svn.apache.org/r1507870 This should allow you to perform SCI detection separately from full ContextConfig. Does that help for your application? It helps a bit. But it's actually the scan for HandlesTypes references that I need to modify (populating the initializerClassMap in ContextConfig) - the SCIs are all discovered correctly, but their handlers are not unless they are in /WEB-INF/classes or /WEB-INF/lib/*.jar. (In reply to Dave Syer from comment #1) > I played around with the Tomcat embedded server a bit more and found that it > actually is relatively easy (if obscure) to switch on SCI: > > ContextConfig contextConfig = new ContextConfig(); > context.addLifecycleListener(contextConfig); Aside: This is as expected if you are using addContext() vs addWebapp(). I have updated the Javadocs for the Tomcat class to try an make that clearer. I'm sure there is scope for further improvement to the docs. Patches welcome. Changing back to a bug as all classes should be scanned unless excluded via JARs to skip. We should also check that classes deployed to CATALIBA_[BASE/|HOME]lib are scanned for matches to @HandlesTypes This has been fixed in trunk. All class path entries are now scanned for matches to @HandlesTypes. |