1 Reply Latest reply on Feb 11, 2004 11:10 AM by starksm64

    When does EJBContext callerPrincipal get set and cleared?


      When does the caller prinicipal get cleared and set?

      We have had a problem migrating to JBoss 3.2.2 where EJBContext.getCallerPrincipal() throws an IllegalStateException. It worked in 3.2.1, but seems that the EJBContext gets invalidated in 3.2.2 outside some execution scope.

      We are caching an EJBContext in ThreadLocal storage, then pulling it out during our SecurityProxy handling (we wrote a custom SecurityProxy which is only invoked when there is a callerPrincipal). We then clear the cached EJBContext when the Transaction ends so that we don't get another user's data the next time a new Tx executes in that thread.

      thanks all,
      d.

        • 1. Re: When does EJBContext callerPrincipal get set and cleared
          starksm64

          It gets set when the invocation comes in and its cleared when the ctx is return to the pool. Why can't you obtain the ejb context from the invocation?

          public Object invoke(final Invocation mi) throws Exception
          {
           EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext();
           Principal p = ctx.getEJBContext().getCallerPrincipal();
          ...
          }