jersey
  1. jersey
  2. JERSEY-1907

Jersey Spring : Application instanciated twice in recent tomcat servers

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Invalid
    • Affects Version/s: 1.16, 1.17, 1.18
    • Fix Version/s: 1.17
    • Component/s: extensions
    • Labels:
      None
    • Environment:

      Tomcat 7.0.32
      Jersey 1.17 / 1.18
      Jersey-spring 1.17 / 1.18

      Description

      I'm using jersey and jersey spring and was before using Tomcat 7.0.25 without issues. Due to a third-party bug induced by the bug I'll describe, I have noticed an odd problem when using Tomcat 7.0.32.

      The issue is the following :

      • I'm using class extending PackagesResourceConfig to manage my app configuration
      • I'm using Spring ServletContainer
      • When the app launches in Tomcat 7.0.32 a first instance of my Config class is created
      • If I call directly an url corresponding to the REST servlet, it works fine
      • When I request any file outside the REST url-pattern on the same tomcat server, my app configuration is instanciated a second, which is not normal at all and did not happen before (and has side effects on my app)

      I've done some debugging and it seems that in 7.0.32 tomcat instanciates two distinct servlets to honor those requests :

      • During the web app launch, the SpringServlet seems correctly instanciated
      • When making a classic web call outside of jersey url mapping, it seems Tomcat tries to use Jersey ServletContainer directly to answer the request, and that's when my app configuration is called a second time.

      I thought it was only a tomcat issue at first, but it seems more than the relationship between SpringServlet and ServletContainer causes some misbehaviors.

      Tomcat impacted classes seem to be around ContainerBase.java and its new subclass StartChild which seems to instanciate a "daughter" class where before only the "mother" SpringServlet class was instanciated. Moreover, it seems the daughter class path mapping is wrong which causes her to try to answer to requests which don't concern jersey.

      Please help me or feel free to give me ideas of how to get around this problem which impacts many of my apps...

        Activity

        Hide
        Jakub Podlesak added a comment -

        From what you described it seems there is a bug in Tomcat, not in Jersey. Could you please explain some more, why you think this is caused by Jersey?

        Show
        Jakub Podlesak added a comment - From what you described it seems there is a bug in Tomcat, not in Jersey. Could you please explain some more, why you think this is caused by Jersey?
        Hide
        Jakub Podlesak added a comment -

        Closing as invalid, as from what you wrote this is a Tomcat issue.
        Namely it is weird why Tomcat instantiates another Jersey Spring Servlet for URL pattern, that does not match your Servlet configuration.
        IFUC there is nothing Jersey could do about this.

        Please provide some additional details on why you think this is a Jersey bug if you want to re-open the bug report. Thanks.

        Show
        Jakub Podlesak added a comment - Closing as invalid, as from what you wrote this is a Tomcat issue. Namely it is weird why Tomcat instantiates another Jersey Spring Servlet for URL pattern, that does not match your Servlet configuration. IFUC there is nothing Jersey could do about this. Please provide some additional details on why you think this is a Jersey bug if you want to re-open the bug report. Thanks.

          People

          • Assignee:
            Unassigned
            Reporter:
            baudryvincent
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: