ClassCastException on PortableRemoteObject.narrow
843829Nov 9 2003 — edited Nov 9 2003I have a ClassCastException when i try to reference my EJB on client.
It is a stateless session bean, with CMP.
I use JBoss 2.4.10. Seems that he deploys the JAR correctly.
I tried the same with JBoss 3.2.2, shows the same result.
Following are the client messages:
CLASSPATH=.;j2ee.jar;jboss-client.jar;jnp-client.jar
Received home from JNDI: jndi/EjbCommandDispatcherHome, class $Proxy0, implements interface fri.patterns.clientserver.command.ejb.EjbCommandDispatcherHome
null
java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
Following is my code:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory"); env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
env.put(Context.PROVIDER_URL, "localhost");
InitialContext initialContext = new InitialContext(env);
Object objRef = initialContext.lookup("jndi/EjbCommandDispatcher");
System.err.println("Received home from JNDI: "+objRef+", "+objRef.getClass()+", implements "+objRef.getClass().getInterfaces()[0]);
Object homeObj = PortableRemoteObject.narrow(objRef,EjbCommandDispatcherHome.class); // crash!
EjbCommandDispatcherHome home = (EjbCommandDispatcherHome)homeObj;