[jsr356-experts] Re: [jsr356-users] Re: Re: Server deployment

From: Mark Thomas <mark_at_homeinbox.net>
Date: Sat, 01 Dec 2012 10:24:15 +0000

On 30/11/2012 22:00, Rajiv Mordani wrote:
> Including Shing Wai in this thread.
> - Rajiv
> On 11/30/12 1:56 PM, Rajiv Mordani wrote:
>> Not sure if this will go to the jsr356-experts as I am not a member of
>> the list but the fragments case that you describe is true if you have
>> defined fragments. Otherwise what Jitu has described is the correct
>> behavior. Note you don't need to define fragments if you don't want to.

Hang on a second. We spent a long time in the Servlet EG defining the
(lack of a) relationship between metadata-complete and SCIs / @HandlesTypes.

Shing Wai proposed a number of changes and there we no objections:

I assume that when you say "defined fragments" you mean included a
web-fragment.xml in a JAR file.

So the situation we are considering is:
- main web.xml has metadata-complete=true
- the main web.xml has no ordering elements
- no JARs have a web-fragment.xml defined
- a JAR in WEB-INF/lib has an SCI defined
- the SCI has a @HandlesType for @WebSocketEndpoint
- a class exists somewhere in WEB-INF/lib or WEB-INF/classes that is
  annotated with @WebSocketEndpoint

Using the clarifications from Shing Wai's e-mail above:

From the updated
There is no <absolute-ordering> element so no JARs will be excluded from
scanning for SCIs.

From the updated 8.2.4
The @HandlesTypes annotation is applied irrespective of the setting of

So the SCI will be used and the @HandlesType annotation will be applied.
Hence all classes in the web application will be scanned for the
@WebSocketEndpoint annotation.

This is reinforced by the updated 8.1 that states:
If “metadata-complete” is set to "true", the deployment tool MUST ignore
any servlet annotations that specify deployment information

Note the "servlet annotations", not "all annotations".


>> - Rajiv
>> On 11/30/12 1:00 PM, Mark Thomas wrote:
>>> On 30/11/2012 19:33, Jitendra Kotamraju wrote:
>>>> On 11/30/2012 12:49 AM, Mark Thomas wrote:
>>>>> Long version:
>>>>> metadata-complete controls whether or not a Servlet container scans
>>>>> JARs for Servlet annotations (Servlets, Filters and Listeners). The
>>>>> mechanism by which other components can scan for classes of interest
>>>>> is the @HandlesTypes annotation on a ServletContextInitializer (SCI).
>>>>> metadata-complete has no impact on SCI processing. If we take the
>>>>> approach suggested above we would have to package our own class
>>>>> scanning within the WebSocket JAR.
>>>> I think that is incorrect. metadata-complete impacts SCI
>>>> processing. It
>>>> impacts the complete scanning of *all* annotations not just servlet
>>>> annotations.
>>> Your thinking is wrong and I am speaking with my Servlet 3.1 EG member
>>> hat on.
>>> metadata-complete has no impact on SCI processing. See
>>> http://java.net/jira/browse/SERVLET_SPEC-36.
>>> The short-version:
>>> metadata-complete controls scanning for the Servlet/Filter/Listener
>>> annotations.
>>> SCIs are controlled by fragment ordering. Only fragments included in the
>>> order are scanned for SCIs and only fragments included in the order are
>>> then scanned for matches to any @HandlesTypes.
>>> While the wording of the Servlet 3.0 specification was far from clear,
>>> the recent discussion around SERVLET_SPEC-36 has clarified what the
>>> Servlet 3.0 EG intended. This clarification will be in the 3.1 spec (and
>>> I hope back-ported to the 3.0 spec)
>>> Mark