users@jersey.java.net

Thread access to _at_Context objects?

From: Chris Hubick <chris_at_hubick.com>
Date: Fri, 23 Oct 2009 13:22:48 -0600

Hi,

I am in the process of porting my Servlet application to Jersey using
it's ServletContainer. Currently, until I can transition to the
JAX-RS API, @Context HttpServletRequest/Response references are used
for things like "Accept-Language" header access, response URL
encoding, etc.

I have found that if I attempt to access these objects from a spawned
worker thread, it throws java.lang.IllegalStateException inside
com.sun.jersey.server.impl.container.servlet.ThreadLocalInvoker.

I run all Servlet API access through a ServletUtil class which
synchronizes all calls, which works fine directly under Tomcat. How
can I make this work under Jersey?

Will finishing the port to the JAX-RS (HttpHeaders/UriInfo/etc) API
solve this, or will I have the same problem?

If it's needed (?), I can construct a synchronization utility class
for JAX-RS calls, like I do for the Servlet API, but since not even
that appears to be working, I'm scared I have to somehow funnel all
calls from the worker threads back through the original calling
thread, or replicate all the data I need access to?

Much Thanks!

-- 
Chris Hubick
mailto:chris_at_hubick.com
http://www.hubick.com/chris/