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:
  1. use an Application class

  2. In this case you'd have the following in your web.xml: <servlet> <servlet-name>jersey-serlvet</servlet-name> <servlet-class> org.glassfish.jersey.servlet.ServletContainer </servlet-class> <init-param> <param-name>javax.ws.rs.Application</param-name> <param-value>mjb44.auth.dbdalrest.RestApplication</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>jersey-serlvet</servlet-name> <url-pattern>/jax-rs/*</url-pattern> </servlet-mapping> … 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));
            }
            }
  3. use package scanning

  4. In this case you don't need an javax.ws.rs.core.Application class and your web.xml looks like the following: <servlet> <servlet-name>jersey-serlvet</servlet-name> <servlet-class> org.glassfish.jersey.servlet.ServletContainer </servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>mjb44.auth.dbdalrest</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>jersey-serlvet</servlet-name> <url-pattern>/jax-rs/*</url-pattern> </servlet-mapping>