On Thu, Apr 22, 2010 at 7:41 AM, Laird Nelson <ljnelson_at_gmail.com> wrote:
> As I understand it, if I'm deploying to a Java EE 6 servlet container,
> I wouldn't need a web.xml file at all, nor any servlet annotations, on
> any class inside my war file. This fills me with a faint sense of
> dread :-).
Following up to my own email here. There's a section (2.3.2) in the
JAX-RS specification that reads:
"When using the pluggability mechanism the following conditions MUST be met:
• If no Application subclass is present the added servlet MUST be named:
javax.ws.rs.core.Application
and all root resource classes and providers packaged in the web
application MUST be included in the
published JAX-RS application. The application MUST be packaged with a
web.xml that specifies a
servlet mapping for the added servlet."
Now, the context of this paragraph is JAX-RS implementations. So it
would appear that it is the JAX-RS implementation that is responsible
for adding the servlet (clearly), but (less clearly to me) it is also
the implementation in this case that would define the servlet. That
is: I don't need to ship with a web.xml, because one will effectively
be inferred and used for me.
I'd like to focus in on the last sentence here:
"The application MUST be packaged with a web.xml that specifies a
servlet mapping for the added servlet."
Again, we're in the context of talking about JAX-RS implementations,
not end users (like me). But I want to be extremely clear about this:
is this sentence saying that JAX-RS implementations (like Jersey) must
ensure, somehow, that an end-user JAX-RS application gets a web.xml,
even if it wasn't packed up with one?
Or is it actually the case that I need to pack my JAX-RS application
up with a web.xml? If so, what is the minimal information I must
include in this file, given that I have no servlets to deploy?
Presumably I'd have one <servlet-class> element specifying
"javax.ws.rs.core.Application" in such a case?
I have no intention at this time of supplying an Application class,
since I don't know my classpath at coding time (this is a big project
sprawled out across lots of modules), in case that matters.
Best,
Laird