Friday, March 18, 2011


If you get a
"No valid security context for the caller identity"

when your MDB is run, you can either annotate it with:

or, on JBoss, with

otherwise you can:

InitialContext ic = new InitialContext();
SessionContext sc = (SessionContext) ic.lookup("java:comp/EJBContext");
Principal p = sc.getCallerPrincipal();

(you can also use @Resource and have the container inject the EJBContext)

but this will not allow you to change principal on the go...

here the Principal javadoc

No comments: