<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Help with MDB getting "Security Context is null" error when accessing the JMX RMI Adaptor
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/santoro63">Alexandre Santoro</a> in <i>JMX Development</i> - <a href="http://community.jboss.org/message/586821#586821">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I am at my wit's end and would appreciate some help with this problem. Here's what's happening.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I am running JBoss AS 5.1.0.GA and have created an mdb with an onMessage() method that looks like this:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: courier new,courier;">public void onMessage(Message m) {</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160; processMessage(m);</p><p>&#160;&#160;&#160;&#160; LOG.info("finished processing " + m");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: courier new,courier;">}</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The processMessage method eventually gets the RMIAdaptor from jndi and makes a call to it. </p><p><span style="font-family: arial,helvetica,sans-serif;">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:</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>16:56:47,994 ERROR [JmsServerSession] Unexpected error delivering message delegator-&gt;JBossMessage[21256369076322305]:PERSISTENT, deliveryId=0</p><p>javax.ejb.EJBException: RuntimeException</p><p>&#160;&#160;&#160; at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:417)</p><p>&#160;&#160;&#160; at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:209)</p><p>&#160;&#160;&#160; at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)</p><p>&#160;&#160;&#160; at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:415)</p><p>&#160;&#160;&#160; at org.jboss.ejb.Container.invoke(Container.java:1029)</p><p>&#160;&#160;&#160; at sun.reflect.GeneratedMethodAccessor376.invoke(Unknown Source)</p><p>&#160;&#160;&#160; at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)</p><p>&#160;&#160;&#160; at java.lang.reflect.Method.invoke(Method.java:597)</p><p>&#160;&#160;&#160; at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)</p><p>&#160;&#160;&#160; at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)</p><p>&#160;&#160;&#160; at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)</p><p>&#160;&#160;&#160; at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)</p><p>&#160;&#160;&#160; at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)</p><p>&#160;&#160;&#160; at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:169)</p><p>&#160;&#160;&#160; at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:118)</p><p>&#160;&#160;&#160; at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:209)</p><p>&#160;&#160;&#160; at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:195)</p><p>&#160;&#160;&#160; at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)</p><p>&#160;&#160;&#160; at org.jboss.ejb.plugins.inflow.MessageEndpointInterceptor.delivery(MessageEndpointInterceptor.java:249)</p><p>&#160;&#160;&#160; at org.jboss.ejb.plugins.inflow.MessageEndpointInterceptor.invoke(MessageEndpointInterceptor.java:128)</p><p>&#160;&#160;&#160; at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:74)</p><p>&#160;&#160;&#160; at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:101)</p><p>&#160;&#160;&#160; at $Proxy293.onMessage(Unknown Source)</p><p>&#160;&#160;&#160; at org.jboss.resource.adapter.jms.inflow.JmsServerSession.onMessage(JmsServerSession.java:178)</p><p>&#160;&#160;&#160; at org.jboss.jms.client.container.ClientConsumer.callOnMessageStatic(ClientConsumer.java:160)</p><p>&#160;&#160;&#160; at org.jboss.jms.client.container.SessionAspect.handleRun(SessionAspect.java:831)</p><p>&#160;&#160;&#160; at org.jboss.aop.advice.org.jboss.jms.client.container.SessionAspect_z_handleRun_494204024.invoke(SessionAspect_z_handleRun_494204024.java)</p><p>&#160;&#160;&#160; at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)</p><p>&#160;&#160;&#160; at org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:170)</p><p>&#160;&#160;&#160; at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:86)</p><p>&#160;&#160;&#160; at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)</p><p>&#160;&#160;&#160; at org.jboss.jms.client.delegate.ClientSessionDelegate.run(ClientSessionDelegate.java)</p><p>&#160;&#160;&#160; at org.jboss.jms.client.JBossSession.run(JBossSession.java:199)</p><p>&#160;&#160;&#160; at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:234)</p><p>&#160;&#160;&#160; at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:205)</p><p>&#160;&#160;&#160; at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:260)</p><p>&#160;&#160;&#160; at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)</p><p>&#160;&#160;&#160; at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)</p><p>&#160;&#160;&#160; at java.lang.Thread.run(Thread.java:619)</p><p>Caused by: java.lang.IllegalStateException: Security Context is null</p><p>&#160;&#160;&#160; at org.jboss.ejb.plugins.SecurityActions$RunAsIdentityActions$2.pop(SecurityActions.java:143)</p><p>&#160;&#160;&#160; at org.jboss.ejb.plugins.SecurityActions.popRunAsIdentity(SecurityActions.java:244)</p><p>&#160;&#160;&#160; at org.jboss.ejb.plugins.RunAsSecurityInterceptor.process(RunAsSecurityInterceptor.java:139)</p><p>&#160;&#160;&#160; at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:103)</p><p>&#160;&#160;&#160; at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I have tried setting the unauthenticatedIdentity property in the &lt;application-context name="other"&gt; element, as well as </p><p>including the &lt;run-as&gt; element in the ejb-jar.xml descriptor for this bean. No matter what I do I get the same error. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>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?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks for your help in advance,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>- Alex</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/586821#586821">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JMX Development at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2105">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>