configuration for Jersey 2 in Tomcat 8.5
There is some code in my playground
here and (more recently)
here that shows how this is done.
More information and additional options (which I have not fully or conclusively explored)
are available here.
dependencies
This is the IVY file that I used (contains some extra dependencies I don't have time to trim right now).
web.xml
Regarding the web.xml there's two options I've discovered to work:
use an Application class
In this case you'd have the following in your web.xml:
jersey-serlvet
org.glassfish.jersey.servlet.ServletContainer
javax.ws.rs.Application
mjb44.auth.dbdalrest.RestApplication
1
jersey-serlvet
/jax-rs/*
… and also define a javax.ws.rs.core.Application class which would return your
actual resources:
package mjb44.auth.dbdalrest;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
public class RestApplication extends Application {
public Set> getClasses() {
return new HashSet>(Arrays.asList(UserDatabaseResource.class));
}
}
use package scanning
In this case you don't need an javax.ws.rs.core.Application class and your web.xml looks like the following:
jersey-serlvet
org.glassfish.jersey.servlet.ServletContainer
jersey.config.server.provider.packages
mjb44.auth.dbdalrest
1
jersey-serlvet
/jax-rs/*