No valid security context for the caller identity
Issue
I have an EJB that contains the following code
public @Stateless
class SecIDBean implements SecIDRemote, SecIDLocal {
@Resource SessionContext ctx;
public String sayHello() {
ctx.getCallerPrincipal().getName();
when the method is called remotely or locally without credential the call ctx.getCallerPrincipal().getName() throws the exception :
No valid security context for the caller identity
I still want to be able to get the caller name in case there is a one. I expect that this call returns "Anonymous" or at worse returns a null. How can I avoid this exception please ?
Environment
Red Hat JBoss Enterprise Application Platform 5.2.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.