Jira issue: http://jira.jboss.org/jira/browse/JBAS-4992
When configuring the jndi.properties to use the org.jboss.iiop.naming.ORBInitialContextFactory, stateful session beans that hold a reference to the java:comp/env context fail to passivate because the factory sets the "java.naming.corba.orb" env property with a reference to the ORB used by JBoss. This is needed so that the NamingContexts (and thus, the IIOP stubs) retrieved by the lookup process are registered with JacORB (and not with Sun's ORB). This is important because JacORB is where all interceptors are configured, and if the stubs get registered with a different ORB instance some services may not work because of the absence of the correct interceptors.
When a stateful session that holds a reference to the java:comp/env context is passivated, an error occurs because it tries to serialize the context and the ORB ref is not serializable. As the specs make it clear that references to the java:comp/env context must be passivated, we need to find a way to fix this. My first idea is to implement the writeObject and readObject methods in org.jboss.jnp.interfaces.NamingContext, so that writeObject removes the ORB reference and readObject restores it (doing some very similar to CorbaORB.getInstace()).