users@servlet-spec.java.net

[servlet-spec users] Re: Should Servlet 3.0 compliant Web Container process @WebServlet annotation if app's web.xml is version 2.5?

From: Mark Thomas <markt_at_apache.org>
Date: Fri, 08 Jun 2012 18:16:59 +0100

On 08/06/2012 00:59, Rajiv Mordani wrote:
> Like Bill pointed out in the thread - there are some exceptions to the
> rule. This is one of the exceptions where metadata-complete does not
> disable scanning of ServletContainerInitializers and related annotations
> (HandlesTypes) bundled with the application. This was one of the key
> pluggability contracts that was added in Servlet 3.0.


So I take it then that your view is that it is acceptable for a web
application written to the 2.5 API that runs one way on a 2.5 container
to run differently on a 3.0+ container due to 3rd party libraries using
3.0+ annotations?

I do not find this at all acceptable. It breaks the principle of least
surprise. However, I suspect based on what has already been said that I
am not going to win this argument. On that basis I believe we need to do
the following:

1. Correct the text of section 1.6.2 of the Servlet 3.0 specification to
make clear that some annotations (define which ones) will always be
scanned for regardless of the setting of meta-data complete.

2. Add a clear warning to this section that applications written to
previous specification versions may behave differently on new containers
due to the presence of annotations (e.g. in third party libraries).

Mark


>
> - Rajiv
>
>
> On 6/1/12 12:07 PM, Mark Thomas wrote:
>> On 25/05/2012 09:22, Jan Bartel wrote:
>>> Rajiv,
>>>
>>> On 24 May 2012 23:59, Rajiv Mordani<rajiv.mordani_at_oracle.com> wrote:
>> <snip/>
>>
>>>> The application would explicitly use an annotation in the code - so the
>>>> behavior will be expected by the application by the fact that it
>>>> used the
>>>> particular annotation.
>>> Not necessarily. As per http://java.net/jira/browse/SERVLET_SPEC-36, a
>>> servlet 3.0 container is required to look for
>>> ServletContextInitializers inside WEB-INF/lib jars. If an application
>>> uses a jar that happens to have one of these then when the app is
>>> deployed on a 2.5 compliant container it may have different and
>>> unexpected behaviour on a servlet 3.0 container. Unless a user sees
>>> the source of all the jars in WEB-INF/lib there's no way for them to
>>> know that such annotations are present.
>> Ping.
>>
>> I have yet to see a response to this particular point.
>>
>> And the same point applies to all the other new 3.0 annotations if
>> meta-data complete is not specified.
>>
>> I understand why the specification is written the way it is but the
>> above is one of the less pleasant side-effects. Is this really the way
>> we want to go?
>>
>> Mark