• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Execution of EJB Client

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic