Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] How to prevent No Spring WebApplicationInitializer types detected on classpath?

Just a quick clarification.

The goal of metadata-complete="true" is to say that the metadata in the web.xml is complete.
It has no effect on the scanning or not classpath information in WEB-INF/classes and WEB-INF/lib

Here's 2 examples where scanning is still required, regardless of what metadata-complete says.

1) ServletContainerInitializer
    In order to support this, the services for these are looked up from META-INF/services/javax.servlet.ServletContainerInitializer and instantiated.
    Then any @HandlesTypes annotations on these SCI implementations are identified.
    All of the HandlesTypes entries are then required to be scanned for in the WEB-INF/classes and WEB-INF/lib tree.
    Then the server calls the SCI.onStartup(Set<Class<?>>, ServletContext) with the entire set of classes matching the @HandlesTypes entries.
2) JSR-356 javax.websocket @ServerEndpoint and ServerApplicationConfig support.
    When you have websocket endpoints in the mix, they have to be scanned for in order to be installed.
    When you have ServerApplicationConfig instances, those have to be invoked to (potentially) filter the found endpoints from the scan.

In short, don't rely on metadata-complete="true" to mean "will not scan WEB-INF/classes and WEB-INF/lib jars".
That's simply not true (anymore)

Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts

On Wed, Oct 2, 2013 at 10:48 AM, Miguel Almeida <migueldealmeida@xxxxxxxxx> wrote:
Thanks for the quick reply Rossen,

On Wed, Oct 2, 2013 at 5:40 PM, Rossen Stoyanchev <rstoyanchev@xxxxxxxxxxxxx> wrote:
You must be pulling in spring-web as a dependency. That's not required
for dependency injection so you might want to check what's pulling it
Indeed. struts2-spring-plugin is using spring-web. Also, jmesa 3.0.4 is also using it (this one seems kind of odd).

So I guess I need to go down the other way, but to be honest I do not quite understand what I am supposed to be doing.
This is what I understood so far:
1) The goal of  metadata-complete=true is to tell the container that it doesn't need to scan the lib/ folder for any Servlet 3.0 specific annotations
2) This is desired, because I am not using any
3) The presence of spring-web somehow forces Jetty to scan the entire /lib nonetheless (searching for ServletContainerInitializers?)
4) By adding an empty <absolute-ordering/>, we are essentially saying no ServletContainerInitializers are to be searched
5) This is what I need in this case, because this is a Struts application.

I am sure to have said something wrong, but my limited knowledge of ServletContainerInitializers and whatnot is probably hindering these assumptions. Could you care to shed some light?

Once again, thanks for the help!


That said there is a way to include/exclude specific web fragments
through <absolute-ordering> in web.xml. It is a Servlet spec specific
mechanism but also see this commit message:

jetty-users mailing list

jetty-users mailing list

Back to the top