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: Greg Wilkins <gregw_at_intalio.com>
Date: Thu, 31 May 2012 09:51:32 +0200

On 30 May 2012 19:23, Bill Shannon <bill.shannon_at_oracle.com> wrote:
> We don't intend that the behavior of the descriptor changes from release
> to release.

But we have done exactly that with 3.0

> The only issue I'm aware of that's even close to this is what
> should happen if an application written for an older version of the spec
> includes annotations that the older version of the spec didn't know about,
> and is then run on a product that supports a newer version of the spec that
> does know about such annotations.  We would lose much of the ease of use of
> annotations if developers were required to explicitly enable understanding
> of annotations before they could use them.

I don't think we lose very much. Most new applications will be written
with a 3.0 or 3.1 descriptor anyway, so they are already aware that
scanning for annotations and context initialisers will take place.
It is not much to ask of a 2.5 webapp, that if it wants to use these
features then it should simply change the 2.5 to 3.0 or 3.1 in the
header of the web.xml

> And it would be particularly bad
> if an application that previously didn't need a descriptor because it was
> using annotations suddenly was required to have a descriptor to enable use
> of new annotations.

I don't think anybody is saying this. If a web app does not have a
descriptor, then it does not declare a version and thus will obviously
work with the semantics of the container in which it was deployed.


> If you want to run an application in an environment that's limited to exactly
> and only the features available in a previous version of a spec, run it on a
> product that supports only that version of the spec.  Products may also offer
> modes that provide different environments limited to different versions of the
> spec if they believe that this level of compatibility is important.

I think you will find this is unacceptable in many/most production
environments. You will find that containers are updated because of
security fixes or corporate infrastructure beyond the control of the
web application creators. I really don't think it unreasonable to say
that a 2.5 webapp with meta-data complete set should be able to be
deployed without new annotations and servlet context initialisers
being fired (which may be brought in from updated dependencies).

I agree that we don't want to provide fine grained 2.5 compatibility,
but turning off some auto discovery mechanisms for 2.5 webapps is not
that difficult to do. If you want autodiscovery, it is trivial to
update a 2.5 descriptor to 3.x

regards