Skip to content

Instantly share code, notes, and snippets.

@jawher
Created December 3, 2010 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jawher/727137 to your computer and use it in GitHub Desktop.
Save jawher/727137 to your computer and use it in GitHub Desktop.
Configuring Jersey with a servlet container + JSON
import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
import javax.ws.rs.core.Application;
import java.util.HashSet;
import java.util.Set;
public class GfeResources extends Application {
@Override
public Set<Object> getSingletons() {
Set<Object> res = new HashSet<Object>();
res.add(new JacksonJsonProvider());
return res;
}
public Set<Class<?>> getClasses() {
Set<Class<?>> res = new HashSet<Class<?>>();
res.add(FilesystemResource.class);
return res;
}
}
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<servlet>
<servlet-name>RestRestlet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>gfe.server.GfeResources</param-value>
</init-param>
</servlet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment