geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <>
Subject Re: propagate security context across threads?
Date Thu, 12 Mar 2009 18:05:04 GMT

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 package

in original thread:

Callers callers = ContextManager.getCallers();

In worker thread:

try {
//do stuff
} finally {

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.

david jencks

> Thanks,
> -Jeff
> -- 
> View this message in context:
> Sent from the Apache Geronimo - Users mailing list archive at  

View raw message