It is the client that needs to use the org.jboss.naming.NamingContextFactory, not the server jndi.properties.
Thanks for your reply, but as far as I can see the naming properties are cached inside the StatefulHandleImpl at construction-time. So when I call SessionContext.getEJBObject().getHandle() the handle gets constructed inside the server JVM. And these properties are still in use when this handle instance is serialized into the client JVM.
To confirm this in a test environment I switched to the org.jboss.naming.NamingContextFactory on the client side and called
NamingContextFactory.lastInitialContextEnv.get() to get sure the naming properties are cached properly. But even though Handle.getEJBObject() results in the following exception:
java.rmi.RemoteException: Error during getEJBObject; nested exception is:
javax.naming.NameNotFoundException: Name MyBean is not bound in this Context
Only after I changed default/conf/jndi.properties in my JBoss installation directory, the handle worked as expected.