3 Replies Latest reply on Apr 1, 2011 1:02 PM by santoro63

    Help with MDB getting "Security Context is null" error when accessing the JMX RMI Adaptor

    santoro63

      I am at my wit's end and would appreciate some help with this problem. Here's what's happening.

       

      I am running JBoss AS 5.1.0.GA and have created an mdb with an onMessage() method that looks like this:

       

      public void onMessage(Message m) {

       

           processMessage(m);

           LOG.info("finished processing " + m");

       

       

      }

       

      The processMessage method eventually gets the RMIAdaptor from jndi and makes a call to it.

      When the code runs, it prints the LOG.info message in the log file suggesting it has finished processing, but after that fails with the following stack trace:

       

      16:56:47,994 ERROR [JmsServerSession] Unexpected error delivering message delegator->JBossMessage[21256369076322305]:PERSISTENT, deliveryId=0

      javax.ejb.EJBException: RuntimeException

          at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:417)

          at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:209)

          at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)

          at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:415)

          at org.jboss.ejb.Container.invoke(Container.java:1029)

          at sun.reflect.GeneratedMethodAccessor376.invoke(Unknown Source)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)

          at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)

          at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)

          at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)

          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)

          at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:169)

          at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:118)

          at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:209)

          at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:195)

          at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)

          at org.jboss.ejb.plugins.inflow.MessageEndpointInterceptor.delivery(MessageEndpointInterceptor.java:249)

          at org.jboss.ejb.plugins.inflow.MessageEndpointInterceptor.invoke(MessageEndpointInterceptor.java:128)

          at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:74)

          at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:101)

          at $Proxy293.onMessage(Unknown Source)

          at org.jboss.resource.adapter.jms.inflow.JmsServerSession.onMessage(JmsServerSession.java:178)

          at org.jboss.jms.client.container.ClientConsumer.callOnMessageStatic(ClientConsumer.java:160)

          at org.jboss.jms.client.container.SessionAspect.handleRun(SessionAspect.java:831)

          at org.jboss.aop.advice.org.jboss.jms.client.container.SessionAspect_z_handleRun_494204024.invoke(SessionAspect_z_handleRun_494204024.java)

          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

          at org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:170)

          at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:86)

          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

          at org.jboss.jms.client.delegate.ClientSessionDelegate.run(ClientSessionDelegate.java)

          at org.jboss.jms.client.JBossSession.run(JBossSession.java:199)

          at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:234)

          at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:205)

          at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:260)

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

          at java.lang.Thread.run(Thread.java:619)

      Caused by: java.lang.IllegalStateException: Security Context is null

          at org.jboss.ejb.plugins.SecurityActions$RunAsIdentityActions$2.pop(SecurityActions.java:143)

          at org.jboss.ejb.plugins.SecurityActions.popRunAsIdentity(SecurityActions.java:244)

          at org.jboss.ejb.plugins.RunAsSecurityInterceptor.process(RunAsSecurityInterceptor.java:139)

          at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:103)

          at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)

       

      I have tried setting the unauthenticatedIdentity property in the <application-context name="other"> element, as well as

      including the <run-as> element in the ejb-jar.xml descriptor for this bean. No matter what I do I get the same error.

       

      Does anyone what is it that causes this stack trace to happen AFTER the method uses the RMIAdaptor and exits? Am I missing some RMI configuration I am not aware of?

       

      Thanks for your help in advance,

       

      - Alex