Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error: java.lang.ClassCastException

 
Ajoy Sharma
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Be sure, that your Client JAR File is in the CLASSPATH.
Georg
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic