users@jersey.java.net

Integrating Jersey and Spring

From: Brad Lee <s.brad.lee_at_gmail.com>
Date: Sat, 9 Jan 2010 18:45:04 -0500

I'm interested in integrating Jersey and Spring, but not just by deferring
to spring for resource creation (as described here:
http://weblogs.java.net/blog/2007/09/14/integrating-jersey-and-spring), I
want spring to handle routing via the DispatcherServlet and send requests to
Jersey when acceptable.

What I want to do is use spring web MVC to route jersey requests to a Jersey
"Controller" in spring, which will then let Jersey take over and handle the
request. So, the idea is that there does not exist a Jersey filter or
servlet (so no need to configure a SpringServlet or a ServletContainer in
web.xml).

To that end, I have written a Spring MVC Controller implementation that
extends Jersey's ServletContainer. It provides for resource creation just
like the SpringServlet. Then, when the spring framework makes a request, it
delegates the request to the super.service(request, response) method. My
implementation works as expected in the ideal, curl case (calling curl from
the command line), but fails when used in a multi-request webapp
environment. It seems to me that the Threads are going zombie on me; only
the last request is serviced as expected, and all other requests seem to die
immediately when the new request comes in.

I have seen some mailing list threads that refer to similar threading-type
issues, but none seem to be my same problem. Let me know if you need to see
my code or configuration files, I'll be happy to post them.

-Brad