Skip to Content
0
Former Member
Feb 22, 2013 at 04:47 PM

How to get the current user in a session bean?

277 Views

Hi,

in a stateless session bean I'd like to retrieve the user id of the currently logged in portal user.

I tried it with UMFactory.getAuthenticator().getLoggedInUser() and SessionContext.getCallerPrincipal().getName().

UMFactory.getAuthenticator().getLoggedInUser() returns null.

And SessionContext.getCallerPrincipal().getName() ends up in the Exception "javax.ejb.EJBException: ASJ.ejb.003002 EJB Container cannot obtain the security principal, because no security context has been associated with the current thread. Probably the code is executed in system instead of application thread. In order to resolve the error, the code should be executed in an application thread."

Any ideas what could be the problem?

Thanks in advance.

Best regards,

Robert