users@jersey.java.net

[Jersey] Issue with servlets loading after upgrading from Jersey 2.11 to 2.17

From: Price, Loren <Michael.Price_at_netapp.com>
Date: Fri, 15 May 2015 01:04:45 +0000

Hello,

I'm seeing a problem with the newest version of Jersey Server when I have multiple servlets that have custom implementations of javax.ws.core.Application (they actually extend ResourceConfig). We recently updated from Jersey 1.x to 2.17, and I've been seeing issues with some servlets loading twice (and others not being loaded at all). We have 3 in our web.xml file (multiple versions of an API).

The root cause seems to be that upon the creation of the ResourceConfigs, the value stored in the ServletContext attributes via org.glassfish.jersey.servlet.internal.Utils.store is being overwritten, and is causing the wrong Application class to be loaded. I'm not sure if this is a bug, or if I've got something off in my configuration. Rolling back to 2.11 seems to have resolved the issue for me.

Example from web.xml for clarity:

<servlet>
    <servlet-name>v1</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>

    <init-param>
        <param-name>javax.ws.rs.Application</param-name>
        <param-value>com.example.ApplicationConfigV1</param-value>
    </init-param>

    <load-on-startup>5</load-on-startup>
</servlet>


<servlet-mapping>
    <servlet-name>v1</servlet-name>
    <url-pattern>/v1/*</url-pattern>
</servlet-mapping>

Hopefully I've been clear enough about my setup and the issue I'm seeing.

Thanks,

Michael