users@jersey.java.net

[Jersey] Init-params for Jersey 2.0 vs jersey 1.17 in web.xml

From: Surya De <suryade_at_gmail.com>
Date: Tue, 27 Aug 2013 13:54:32 -0400

Hello all,

I am wondering if you could point me in the right direction. I am trying to
upgrade to the latest Jersey 2.2 from 1.17 and am currently facing a
problem when it comes to the web.xml.

Previously we would have our web.xml section that is initializing the
servlet look like so:
  <servlet>
    <servlet-name>Jersey REST Service</servlet-name>

<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
    <init-param>
      <param-name>com.sun.jersey.config.property.packages</param-name>
      <param-value>com.some.package</param-value>
    </init-param>
    <init-param>

<param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
      <param-value>com.some.package.SomeFilter</param-value>
    </init-param>
    <init-param>
      <param-name>com.sun.jersey.spi.container.ResourceFilters</param-name>
      <param-value>com.some.package.AnotherFilter</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>

Now I have changed it to look like so:
  <servlet>
    <servlet-name>Jersey REST Service</servlet-name>

<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
      <param-name>jersey.config.server.provider.packages</param-name>
      <param-value>com.turner.ids</param-value>
    </init-param>
    <init-param>

<param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
      <param-value>com.some.package.SomeFilter</param-value>
    </init-param>
    <init-param>
      <param-name>com.sun.jersey.spi.container.ResourceFilters</param-name>
      <param-value>com.some.package.AnotherFilter</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>


You will note that the servlet-class and the first init-param have changed
but I am not sure how I would go ahead and map the other init-params. Any
guidance would be much appreciated.

Cheers,
Surya