This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes error: java.lang.ClassCastException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "error: java.lang.ClassCastException" Watch "error: java.lang.ClassCastException" New topic
Author

error: java.lang.ClassCastException

Ajoy Sharma
Greenhorn

Joined: Feb 24, 2004
Posts: 18
Hi
Iam facing error : java.lang.ClassCastException. It giving error at this point in my client code : ServerHome serverhome =(ServerHome) javax.rmi.PortableRemoteObject.narrow(obj,ServerHome.class);
could any body tell me plz how can solve it.
code is givin below.
thanks for ur help.
Anand

import javax.ejb.*;
import java.awt.*;
import java.awt.event.*;
import javax.rmi.*;
import java.rmi.*;
import javax.swing.event.*;
import javax.swing.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.util.Hashtable;
import java.util.Properties;
import javax.ejb.CreateException;
public class Client {
public static void main(String[] args){
try{
Properties env = new Properties();
env.put("java.naming.factory.initial","com.sun.jndi.cosnaming.CNCtxFactory");
env.put("java.naming.provider.url", "iiop://localhost:3700");
Context context = new InitialContext(env);
Object obj = context.lookup("ejb/ServerObject"); //Server ejb-name
System.out.println("Working here anand");
ServerHome serverhome =(ServerHome) javax.rmi.PortableRemoteObject.narrow(obj,ServerHome.class);
Server server = serverhome.create();
String Message = JOptionPane.showInputDialog("Enter Your Message");
JOptionPane.showMessageDialog(null, server.performAction(Message) );

}
catch(Exception e){
JOptionPane.showMessageDialog(null ,"Exception is " +e);
}
}
}
Georg Joo
Ranch Hand

Joined: Feb 24, 2004
Posts: 49
Hi
Be sure, that your Client JAR File is in the CLASSPATH.
Georg


SCJP, SCWCD, SCBCD<br /> <br />Vienna, Austria
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error: java.lang.ClassCastException
 
Similar Threads
NoIntailContextException
HOW TO: Deploy an Application Client in WAS
PoratableRemoteObject
NoInitialContext Exception
ClassCastException in websphere