On Mar 12, 2009, at 10:53 AM, jlowe wrote:


I have a use case where a web application needs to initiate an EJB operation that may take considerable time, so therefore I want the EJB method to be
called asynchronously.  I'm using a message queue provided by the
spring-integration project.

The problem I'm having is that when the message is popped off the queue (on a new thread) and the EJB operation is called, the security context is gone,
and the EJB throws a security related exception.

Is there any way to get the security context, so that I can put it in the
message header, and then put it in the new thread?

classes are in org.apache.geronimo.security package

in original thread:

Callers callers = ContextManager.getCallers();

In worker thread:

ContextManager.setCallers(callers.getCurrentCaller(), callers.getNextCaller());
try {
//do stuff
} finally {
  ContextManager.popCallers(null);
}

There might be a memory leak if you don't use a thread pool because popCallers(null) is calling thrreadLocal.set(null) rather than threadLocal.remove(): I'm not sure what happens with threadLocal.set(null) if the thread is then discarded.

thanks
david jencks



Thanks,
-Jeff



--
View this message in context: 
http://www.nabble.com/propagate-security-context-across-threads--tp22482052s134p22482052.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Reply via email to