Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

error: java.lang.ClassCastException  RSS feed

Ajoy Sharma
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

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){
Properties env = new Properties();
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
Be sure, that your Client JAR File is in the CLASSPATH.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!