users@jersey.java.net

Re: using jersey with glassfish and eclipse

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 30 Oct 2007 09:54:05 +0100

Jakub Podlesak wrote:
> Hi Sudhakar,
>
> There is a simple hello world webapp bundled along with Jersey.
> In [examples/HelloWorldWebApp] subdirectory you can try:
> % ant
> % $AS_HOME/bin/asadmin start-domain
> % $AS_HOME/bin/asadmin deploy dist/SimpleServlet.war
>
> Then look at [build.xml] file for:
>
> - taskdef name="rbpt"
> - target name="-pre-compile"
>
> which include the important part of "configuration".
>
> The above mentioned was also described in
> an old version of [docs/getting-started.html] document,
> but I do not know where it ended up.
> Might be Paul could know?
>

This area needs some major rework. I want to revamp all of this and
improve the implementation. Two possible improvements:

1) JAX-WS 2.1 and JAXB 2.1 will be included in Java SE 6 update 5 (IIRC)
    that means i can remove a whole bunch of class loader tricks; and

2) potentially removing it completely and depend on the proof of concept
    of using the byte code processor that Frank has produced.


The best thing to do at the moment is look at the web/WEB-INF/web.xml
and the "pre-compile" target bits of the build.xml and adapt to your own
build infrastructure.

You don't need to use the rbpt compile task if you:

1) don't want to create WADL; and

2) can manage the set of root resource classes yourself.

The init-param:

     webresourceclass

of the servlet:

     com.sun.ws.rest.spi.container.servlet.ServletContainer

in the web.xml needs to point to the fully qualified class name of an
implementation of the interface:

     com.sun.ws.rest.api.core.ResourceConfig

It is recommend that you extend the class:

     com.sun.ws.rest.api.core.DefaultResourceConfig

which implements ResourceConfig and has default settings configured, for
example like this:

     public class RootResources extends DefaultResourceConfig {
         public RootResources() {
             super(RootResourceA.class, RootResourceB.class);
         }
     }

Where the classes RootResourceA and RootResourceB are root resources
annotated with a UriTemplate on the class.

Hope this helps,
Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109