1 Reply Latest reply on Jan 4, 2012 2:26 PM by inet_gbo

    Security Context at Startup-Time

    semubiz

      Hi everyone

       

      Is it somehow possible for Startup-Bean (@Startup on Singleton-EJB) annotation to have a security context set? Possibly run in anonymous mode?

       

      The Startup-Bean initially calls a Session Bean where I would like to access SessionContext.getCallerPrincipal(). That throws an exception: "java.lang.IllegalStateException: No security context established". I could program a workaround programmatically, but I would have to overload methods of several SessionBeans.

       

      Thank you

        • 1. Re: Security Context at Startup-Time
          inet_gbo

          Hi,

           

          did you find an answer?

           

          I have a similar problem with a StartupServlet configured with run-as.

          {code}

          public class TestServlet extends HttpServlet {

              @Inject

              private Principal principal;

           

              public void init(ServletConfig config) throws ServletException {

                  String caller = principal.getName(); // throws  java.lang.IllegalStateException: No security context established

                  ...

              }

          {code}

           

          Thanks

          Günther