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...