Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

ClassCastException on PortableRemoteObject.narrow

843829Nov 9 2003 — edited Nov 9 2003
I 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;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 7 2003
Added on Nov 9 2003
1 comment
114 views