2 Replies Latest reply on Aug 30, 2002 12:25 PM by Oriol

    calling getCallerPrincipal() in ejbCreate fails

    Michael Christen Newbie

      Hi

      I try to get the callerprincipal inside the ejbCreate method of a session bean:

      public void ejbCreate() {
      userId = context.getCallerPrincipal().getName();
      }

      but this call leads to the following exception:
      java.lang.IllegalStateException: No security context set
      at org.jboss.ejb.EnterpriseContext$EJBContextImpl.getCallerPrincipal(EnterpriseContext.java:248)
      at com.swisscom.swissbill.ejb.session.UserSessionBOBean.ejbCreate(Unknown Source)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.createSession(StatefulSessionFilePersistenceManager.java:163)
      at org.jboss.ejb.StatefulSessionContainer.createHome(StatefulSessionContainer.java:441)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invokeHome(StatefulSessionContainer.java:756)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:104)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:215)
      at org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invokeHome(StatefulSessionInstanceInterceptor.java:128)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:98)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:167)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:109)
      at org.jboss.ejb.StatefulSessionContainer.invokeHome(StatefulSessionContainer.java:368)
      at org.jboss.ejb.Container.invoke(Container.java:726)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:362)
      at java.lang.reflect.Method.invoke(Native Method)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
      at sun.rmi.transport.Transport$1.run(Transport.java:152)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:148)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:706)
      at java.lang.Thread.run(Thread.java:484)

      If i use context.getCallerPrincipal() in a 'normal' method (not ejbCreate) it works really fine. Thus i think i don't do anything wrong...
      The EJB2.0 Specification says that it should possible to get the callerPrincipal from inside the ejbCreate method.
      So I think this could be a bug in JBoss!?!

      I already searched the WEB and the forum, but found only one similar problem, but without solution:
      http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ anyone give me a hint, where the problem could be?

      My environment:
      IBM jdk 1.3.0
      JBoss 3.0.0
      Linux (Kernel 2.4.18)