tags:

views:

279

answers:

1
+1  Q: 

jersey deployment

Hi,

I have developed a jersy Resource class. Can someone please tell me how can i deploy it on a web/app server. Preferebly tomcat or jboss. Or a better question still, can jersey applications with only a resource class be deployed on a web/app server? If yes, How?

Adhir

+2  A: 

by using web.xml:

<servlet>
    <servlet-name>jersey-servlet</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>com.foo.resources;org.bar.resources</param-value>
    </init-param>
</servlet>

or in Java (without a servlet container):

public class MyConfig extends PackagesResourceConfig {

   public MyApplication() {
      super("com.foo.resources;org.bar.resources");
   }
}

or subclassing Application:

public class MyApplicaton extends Application {

    public Set<Class<?>> getClasses() {
        Set<Class<?>> s = new HashSet<Class<?>>();
        s.add(com.foo.resources.MyResource.class);
        return s;
    }
}
dfa
so i just create a web app in any ide. put the above changes in web.xml, put my resource class in the source forlder of the new webapp and it will be ready to go.. Is it really that simple.
Adhir
thanks a tonne.. works
Adhir