Hi Darran,
I think it now gets i little bit more complicated. Let me try to explain.
For our client application we have the requirement to be able to use multiple users per JVM. in Jboss 4.x and 5.x this could be achieved simply with the JBoss client login module by calling login() method of the module in the current thread for the current user. In JBoss 7 i found the only solution by using the class org.jboss.ejb.client.ThreadLocalContextSelector<...> to set the current EJBClientContext object for the current thread and user. With this approach i was able to call ejb methods with different users in the same jvm -> the server-side CallerPrincipal is correctly set for every call.
The following pseudo code works like a charm, which is the authentication process is only called once per connection:
In the main thread
create connection
set ThreadLocalContext()
lookup the ejb.
called it in a loop
Everything is ok here. But when I start another thread to call the ejb then every call starts the authentication process:
In the main thread:
create connection
set the context
create a new thread and start.
in the run method of the thread:
set threadlocal context for the desired user (which is already successfully authenticated).
lookup the ejb
call it in a loop (now every call must be authenticated)
am I missing something?? Or do I have to do something else instead of using org.jboss.ejb.client.ThreadLocalContextSelector<...>.