On Apr 22, 2010, at 1:24 PM, ljnelson wrote:
> On Thu, Apr 22, 2010 at 6:04 AM, Paul Sandoz [via Jersey]
> <[hidden email]> wrote:
> > Annotate the class with @Provider and make sure it gets registered.
>
> Thank you for responding.
>
> Another question related to registration. The JAX-RS specification
> obviously talks a lot about Application. But then it talks about a
> lot of optional classpath scanning features that providers may wish to
> implement. Then the Java EE 6 specification says that every optional
> deployment/registration feature in JAX-RS must be supported by a Java
> EE 6 container.
>
> I am interested (at this point) only in getting my application running
> in Java EE 6, and for all sorts of reasons do not want to define my
> own Application class (I'd rather have my providers and resources
> discovered). If I simply plunk my .war file containing my resource
> and provider classes down, will they all get recognized?
>
Not quite, because those resource classes require a base path (can be
defined as a URL pattern in the servlet). We wanted to avoid defining
a default base path.
The simplest way to do that without messing around with a web.xml is
to do the following:
@ApplicationPath("/mybasepath")
public class MyApp extends Application {}
and that will result in Jersey picking up all root resource and
provider classes that were scanned by the Web container (note that i
do not know if that will work for an ear deployed in a war, it should,
if not then it is a bug in the Web container). It should be possible
to refer to MyApp as the servlet name if you also want to provide init
params to the servlet and to Jersey.
Paul.