Question
I have developed a Jersey Resource class.
Can someone please tell me how can I deploy it on a Web App server. Preferably 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?
Solution
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;
}
}
OTHER TIPS
Deploying in a servlet container will certainly work if you need the servlet container. Simpler and recommended by Jersey is with Grizzly - http://jersey.java.net/nonav/documentation/latest/user-guide.html#d4e60
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow