<!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;">
Random "Security Context is null" after using SecurityClient
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/snacker">Nathan Ciliberto</a> in <i>Beginner's Corner</i> - <a href="http://community.jboss.org/message/552620#552620">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>We have converted most of our ejb's from 2.1 to 3.0.</p><p>In order to get the client security to work we had to use the following code to setup the client's context for the ejb3:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="padding-left: 30px;">SecurityClient client = SecurityClientFactory.getSecurityClient();<br/>                client.setSimple( username, password );<br/>                client.setVmwideAssociation( true );<br/>                client.login();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Once that code has been executed and the ejb invoked we start seeing <span style="text-decoration: underline;">random</span> errors such as this:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="padding-left: 30px;"><span style="font-size: 8pt;">15:01:01,035 ERROR [CoyoteAdapter] An exception or error occurred in the container during the request processing<br/>java.lang.IllegalStateException: Security Context is null<br/>        at org.jboss.web.tomcat.security.SecurityAssociationActions$PopRunAsRoleAction.run(SecurityAssociationActions.java:156)<br/>        at java.security.AccessController.doPrivileged(Native Method)<br/>        at org.jboss.web.tomcat.security.SecurityAssociationActions.popRunAsIdentity(SecurityAssociationActions.java:302)<br/>        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:193)<br/>        at org.jboss.web.tomcat.service.session.ClusteredSessionValve.handleRequest(ClusteredSessionValve.java:135)<br/>        at org.jboss.web.tomcat.service.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:94)<br/>        at org.jboss.web.tomcat.service.session.LockingValve.invoke(LockingValve.java:62)<br/>        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)<br/>        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)<br/>        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)<br/>        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)<br/>        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)<br/>        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)<br/>        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)<br/>        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)<br/>        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)<br/>        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)<br/>        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)<br/>        at java.lang.Thread.run(Thread.java:619)</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The error is "random"... and it occurs on any of the servlets that we have configured.</p><p><span>For example we've had 32,000 requests (according to </span><a class="jive-link-external-small" href="http://myserver:8090/status?full" target="_blank">http://myserver:8090/status?full</a><span>) but only 99 of these errors.</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>It happens for the servlets/jsps whether they are called directly from the server or via apache by way of mod_jk (ajp3).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Does anyone know why this would happen?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Do we have to setup some "default" security for the servlets/jsps?</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/552620#552620">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in Beginner's Corner at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>