I previously had the following fragment of code inside a servlet (which worked fine):
Context ctx = new InitialContext();
BeanEJB beanEJB = null;
BeanEJBHome beanHome = null;
Object obj = ctx.lookup("ejb/BeanEJB");
beanHome = (BeanEJBHome ) PortableRemoteObject.narrow(obj, BeanEJBHome.class);
However, I moved the above code to the run() method of a new thread I created and now the PortableRemoteObject.narrow() call throws a ClassCastException.
Can anyone help?