ra su

Greenhorn
+ Follow
since Nov 12, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by ra su

Hi,

I have used the following client to invoke the EJB Deployed application using Sun Server. But getting the error message. I have attached the client code.

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, "iiop://localhost:3700");

Context initial = new InitialContext(env);

//Context initial = new InitialContext();
//Context myEnv = (Context)initial.lookup("java:comp/env");

/*Retrieve the Object Found to the name - MyConverter */
Object objref = initial.lookup("MyConverter");
//Object objref = myEnv.lookup("ejb/SimpleConverter");

/*Narrow the Reference to a Home Object which we need. ie., ConverterHome */
ConverterHome home = (ConverterHome)PortableRemoteObject.narrow(objref, ConverterHome.class);

/*Invoke the create method in home interface, to get the Remote Interface which has all the
business methods. These business methods are implemented in Beans class */
Converter currencyConverter = home.create();


When I compile the above getting the message that
java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Porta
bleRemoteObject.java:293)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
at bClient.ConClient.main(ConClient.java:31)

Please let me know if any ideas why this is comingup. I have specified "MyConverter" in JNDI Name field of J2EE Server.