jersey
  1. jersey
  2. JERSEY-1798

JerseyServletContainerInitializer behavior violates JAX-RS 1.1 Spec

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.17
    • Fix Version/s: 1.18
    • Component/s: core
    • Labels:
      None
    • Environment:

      Windows, Java 1.7.0_07-b11, WebLogic 12.1.1.1, Jersey 1.17 as preferred application library

      Description

      Given this example:

      <servlet>
      <servlet-name>bob</servlet-name>
      <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
      <init-param>
      <param-name>javax.ws.rs.Application</param-name>
      <param-value>example.MyApplication</param-value>
      </init-param>
      </servlet>

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

      My resources should only be available at /v1/. What happens is they are available at two paths /v1/ and /resources/*. With the above example I see the following in the log:

      Mar 16, 2013 10:19:22 PM com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer addServletWithApplication
      INFO: Registering the Jersey servlet application, named example.MyApplication, at the servlet mapping, /resources/*, with the Application class of the same name

      To prevent the auto registration of a servlet with a url-pattern of /resources/* I have to use a servlet-name that matches the fully-qualified class name of the application subclass like so:

      <servlet>
      <servlet-name>example.MyApplication</servlet-name>
      <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
      <init-param>
      <param-name>javax.ws.rs.Application</param-name>
      <param-value>example.MyApplication</param-value>
      </init-param>
      </servlet>

      <servlet-mapping>
      <servlet-name>example.MyApplication</servlet-name>
      <url-pattern>/v1/*</url-pattern>
      </servlet-mapping>

      On page 6 of the spec it says: If an Application subclass is present and there is already a servlet defined that has a servlet initialization parameter named javax.ws.rs.Application whose value is the fully qualified name of the Application subclass then no new servlet should be added by the JAX-RS implementation's ContainerInitializer since the application is already being handled by an existing servlet.

      It says nothing about the servlet-name also having to match the class name to prevent adding a new servlet. The servlet-name is the class name when a servlet is added by a JAX-RS implementation (as stated in the next paragraph of the spec) but that is separate from how to prevent the addition of the servlet.

        Activity

        chasetec created issue -
        Marek Potociar made changes -
        Field Original Value New Value
        Fix Version/s 1.18 [ 16284 ]
        Priority Major [ 3 ] Critical [ 2 ]
        Marek Potociar made changes -
        Assignee Libor Kramolis [ libor.kramolis ]
        Marek Potociar made changes -
        Original Estimate 18 hours [ 64800 ]
        Remaining Estimate 18 hours [ 64800 ]
        Libor Kramolis logged work - 03/Nov/13 9:52 PM
        • Time Spent:
          3 hours
           
          wls dev env setup
        Libor Kramolis made changes -
        Remaining Estimate 18 hours [ 64800 ] 15 hours [ 54000 ]
        Time Spent 3 hours [ 10800 ]
        Libor Kramolis made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Libor Kramolis added a comment -

        Have you tried WebLogic 12.1.2 or newer? I guess it is already fixed there.

        Show
        Libor Kramolis added a comment - Have you tried WebLogic 12.1.2 or newer? I guess it is already fixed there.
        Libor Kramolis logged work - 04/Nov/13 10:51 AM
        • Time Spent:
          2 hours
           
          <No comment>
        Libor Kramolis made changes -
        Remaining Estimate 15 hours [ 54000 ] 13 hours [ 46800 ]
        Time Spent 3 hours [ 10800 ] 5 hours [ 18000 ]
        Libor Kramolis logged work - 05/Nov/13 8:17 AM
        • Time Spent:
          1 hour
           
          <No comment>
        Libor Kramolis made changes -
        Remaining Estimate 13 hours [ 46800 ] 12 hours [ 43200 ]
        Time Spent 5 hours [ 18000 ] 6 hours [ 21600 ]
        Hide
        Libor Kramolis added a comment -

        This is already fixed in WebLogic 12.1.2 or newer.

        Show
        Libor Kramolis added a comment - This is already fixed in WebLogic 12.1.2 or newer.
        Libor Kramolis made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Libor Kramolis logged work - 06/Nov/13 6:13 PM
        • Time Spent:
          5 minutes
           
          <No comment>
        Libor Kramolis made changes -
        Remaining Estimate 12 hours [ 43200 ] 0 minutes [ 0 ]
        Time Spent 6 hours [ 21600 ] 6 hours, 5 minutes [ 21900 ]

          People

          • Assignee:
            Libor Kramolis
            Reporter:
            chasetec
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 18 hours
              18h
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 6 hours, 5 minutes Time Not Required
              6h 5m