• Post Reply Bookmark Topic Watch Topic
  • New Topic

Execution of EJB Client  RSS feed

jaya raman
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just started learning EJB and I'm using J2sdkee 1.2.1 for my programs. I created a session Bean, which I had deployed successfully using the j2ee EJB server. After which when I tried running the client, I got the following error:
java.lang.ClassCastException at com.sun.corba.ee.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:296)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at MessageClient.main(MessageClient.java:20)
The client program code is:
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import ejb.ejbproj.message.Message;
import ejb.ejbproj.message.MessageHome;
public class MessageClient
public static void main(String[] args)
Context initial = new InitialContext();
Object objref = initial.lookup("MyMessage");
System.out.println(" initial lookup got....");

MessageHome home =(MessageHome) PortableRemoteObject.narrow(objref,
System.out.println("got the reference....");
ejb.ejbproj.message.Message msg = home.create();
String s = msg.getMessage();
System.out.println("The message retrieved is.."+s);
s="Good afternoon...EJB's fine";
System.out.println("The message retrieved is.."+s);
catch (Exception ex)
System.err.println("Caught an unexpected exception!");

Kindly help me out.
Thanks in advance.
jaya raman
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!