• Post Reply Bookmark Topic Watch Topic
  • New Topic

class cast exception

 
LakshmiNarayana vishnu
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I write one programme using struts,ejb,jboss and tomcat.

when i am calling EJB from stutrs action class i am getting eror called

"Class Cast exception"

here is code where i am getting exception:


try{

Context ctx=new InitialContext(ht);

Object obj=ctx.lookup("ijk");
s="isk";
HelloHome home = (HelloHome) obj;-------------- error where i am getting
//HelloHome home =ctx.lookup("ijk");

Hello hello=home.create();
System.out.println(hello.hello());


please resolve ths problem as early as possible

Thanks in advance

LakshmiNarayana.V
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On some App Servers (Particularly WebSphere) you can't just cast the result of the JNDI lookup to an EJB Home class. You must use the javax.rmi.PortableRemoteObject class. Example:


Note: This thread was initially created in the Struts forum. Since it has nothing to do with Struts, I'm moving it to the EJB forum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!