Version 2

    By default, EJB2 stateful session bean handles in AS/EAP 4.x and 5.x use JNDI to retrieve the EJBObject when getEJBObject() is called on the handle. The JNDI settings used are the last JNDI context used by the running thread which is maintained by org.jboss.naming.NamingContextFactory. You can force specific JNDI settings to be stored in the handle by doing something like this:

    import java.util.Properties;
    import org.jboss.naming.NamingContextFactory;
    import javax.ejb.Handle;
    Properties env = ...;
    Handle handle = sfsb.getHandle();


    Back in JBoss 3.2.7, EJBObject retrieval method used to be based on the invoker that had been used to communicate with the stateful session bean. This method was then substituted by the JNDI method and since EAP 4.3.0.GA_CP05 and 4.2.0.GA_CP07 (JBPAPP-1676) and AS 5.1.0.GA (JBAS-5302), this retrieval method has been restored. By default, the JNDI method is used but if a client wants to use the invoker method, the client should run with -Dorg.jboss.ejb.sfsb.handle.V327=x system property.