cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the current user in a session bean?

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I found out that this occurs when the session bean is called from a custom UWL connector.

So this question is answered and the next one will be how to get the security context/session context in such a scenario.

david_fryda2
Participant
0 Kudos

Hi Robert,

Did you succeed retrieving the context using EJB 3 ?

Thanks

Former Member
0 Kudos

Hi David,

the project was cancelled but in the last running version I retrieved the current user in the custom UWL connector and forwarded the user ID to the session bean. So I didn't succeed in retrieving the context in a session bean.

Best regards,

Robert