3 Replies Latest reply on May 14, 2005 5:52 AM by gdemir

    Cannot obtain inMethodFlag for: getCallerPrincipal

    gdemir

      Hi,

      I have a custom security implementation that works well in previous JBoss versions. However, with JBoss 4.0.2 it gives the following exception. I tried (with full rebuild of my own lib) both with jdk 1.5 and jdk 1.4 (latest versions). What might be going mistakenly here?

      Thanks in advance,
      Gokhan Demir


      java.lang.IllegalStateException: Cannot obtain inMethodFlag for: getCallerPrincipal
      at org.jboss.ejb.AllowedOperationsAssociation.assertAllowedIn(AllowedOperationsAssociation.java:119)
      at org.jboss.ejb.StatelessSessionEnterpriseContext$SessionContextImpl.getCallerPrincipal(StatelessSessionEnterpriseContext.java:196)
      at com.igonline.securityx.jboss.IGCommonSecurityProxy.setEJBContext(IGCommonSecurityProxy.java:87)
      at org.jboss.ejb.plugins.SecurityProxyInterceptor.invokeHome(SecurityProxyInterceptor.java:137)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:212)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invokeHome(StatelessSessionInstanceInterceptor.java:81)
      at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:90)
      at org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:41)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:109)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:389)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:146)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:116)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:121)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
      at org.jboss.ejb.SessionContainer.internalInvokeHome(SessionContainer.java:613)
      at org.jboss.ejb.Container.invoke(Container.java:894)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:534)

        • 1. Re: Cannot obtain inMethodFlag for: getCallerPrincipal
          starksm64

          What has changed is that there is now a valid session ctx for the home invocation. Previously this was not created until needed. This is a bug in the assertion being made to what methods are allowed to invoke the getCallerPrincipal that has not shown up until the change in the session ctx creation was made.

          • 2. Re: Cannot obtain inMethodFlag for: getCallerPrincipal
            starksm64

            No, actually I'm wrong. Stateless session beans are not allowed to call getCallerPrincipal from the ejbCreate/ejbRemove as there is no guarentee of a security context. Stateful session beans are allowed to use getCallerPrincipal from ejbCreate/ejbActivate/ejbPassivate/ejbRemove.

            It is the change in behavior to create the session instance that is showing a problem in security proxy. Not every call of the setEJBContext method will be allowed to use getCallerPrincipal.

            • 3. Re: Cannot obtain inMethodFlag for: getCallerPrincipal
              gdemir

              Thanks for the reply.

              After surrounding the line to setEJBContext in a try-catch block to return immediately on IllegalStateException, it started to work fine.

              In my former code, I had checked a possible null value returned from setEJBContext.

              Best Regards,
              Gokhan Demir