Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Execution of EJB Client  RSS feed

 
jaya raman
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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)
{
try
{
Context initial = new InitialContext();
Object objref = initial.lookup("MyMessage");
System.out.println(" initial lookup got....");

MessageHome home =(MessageHome) PortableRemoteObject.narrow(objref,
MessageHome.class);
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";
msg.setMessage(s);
System.out.println("The message retrieved is.."+s);
msg.remove();
}
catch (Exception ex)
{
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}
}
}

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