I am having the following problem, because my client first runs as the admin. user (i.e., InitialContext has security.principal as admin. user), I could not again run as a different user, even though I have created another initial context having security.pincipal as the new user.
What I see via debugger is that, first, a bean instance was created and keep the SessionContext parameter which has the admin. user as security principal. Then, my test creates the new user, and then it creates an initial context with the new user and locates the bean, however, no bean instance is created, the same session bean instance is used. Later on, when I get current user from the session context, it is still the admin. user, not the newly create user.
On the EJB side, I am getting current user info. from SessionContext's getCallerPrincipal().getName();
I expect to get the newly created user from session context since I am creating initial context with that user, what am I missing?