-
1. Re: Exception while calling EJBs deployed on remote machine
cimetgiu Feb 7, 2003 5:57 AM (in response to srshende)I am a beginner and I have a problem after the lookup, when I had to do narrow.
My client is:
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Hashtable;
public class ProvaClient{
public static void main(String [] args){
java.util.Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "localhost:1099");
env.put("java.naming.factory.url.pkgs",
"org.jboss.naming:org.jnp.interfaces");
try
{
Context ctx = new InitialContext(env);
Object obj = ctx.lookup( "Prova/ProvaEJB" );
ProvaHome home =(ProvaHome)javax.rmi.PortableRemoteObject.narrow(obj, ProvaHome.class);
Prova prova = home.create();
System.out.println( prova.ProvaMetodo());
prova.remove();
}
catch ( Exception e )
{
e.printStackTrace();
System.out.println( "Exception: " + e.getMessage() );
}
}
}
and in the same directory there is Prova.class and ProvaHome.class.
The error when I execute the Client is:
java.lang.ClassCastException
Exception: null
Process terminated with exit code 0
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
at ProvaClient.main(ProvaClient.java:19)
The ejb is on the server, I have it in the Service, and the lookup is right, but the obj returned is null probably, why????
The directory with the Client isn't under the server directory.
Thanks for reply. -
2. Re: Exception while calling EJBs deployed on remote machine
srshende Feb 8, 2003 12:03 AM (in response to srshende)Hello,
That exception is due to existance of a single class in multiple jar files. Hence make sure that there is only one copy of the classes you are using.
Moreover make sure that you have not set : java.naming.provider.url=localhost:1099 option in jndi.properties file or somewhere else in your code this leads to rmi call and gives the same problem for PortableRemoteObject. Hope this helps you.
Regds,
Sanjay