• Post Reply Bookmark Topic Watch Topic
  • New Topic

Class Cast Exception  RSS feed

 
seshu Palamanti
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using WSAD 5.1.1 for testing my CMP entity bean from Universal Test Client.I use JNDI look up to get a ref of my local home interface i got it like this.

Object o = context.lookup("ejb/Sqa_audit_reviewLocalHome");
auditrhome = (Sqa_audit_reviewLocalHome)o;

at line 2. i get this Exception

java.lang.ClassCastException: com.sbc.eworks.sqa.ejb.entity._EJSRemoteCMPSqa_audit_reviewHome_96846b2b_Stub
at com.sbc.eworks.ejb.session.SQAServiceEngineBean.searchByReviewId(SQAServiceEngineBean.java:169)
at com.sbc.eworks.ejb.session.EJSLocalStatelessSQAServiceEngine_d93b245b.searchByReviewId(EJSLocalStatelessSQAServiceEngine_d93b245b.java:87)

MY SERVER CONSOLE HAS THIS TO SAY

ExceptionUtil E CNTR0020E: Non-application exception occurred while processing method "searchByReviewId" on bean "BeanId(SQADatabaseEAR#SQAEJB.jar#SQAServiceEngine, null)". Exception data: java.lang.ClassCastException: com.sbc.eworks.sqa.ejb.entity._EJSRemoteCMPSqa_audit_reviewHome_96846b2b_Stub

CAN ANY PLEASE LET ME KNOW WHAT IS THE PROBLEM???

thanks in advance

Seshu P
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seshu,
Pardon me for stating the obvious, but the "Object" returned by your lookup method is _not_ an instance of "Sqa_audit_reviewLocalHome". Have you tried printing out the actual type, like this:

By the way, the usual way to do the cast is to use the "narrow()" method in class PortableRemoteObject:

Good Luck,
Avi.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Avi,
the normal cast is totally ok here cause he is using the Local interface. And in this case no narrow is required.

bye
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oliver, just because the interface name has "local" in it, doesn't mean it's a local interface. Part of what determines whether an interface is local, or not, is the "ejb-jar.xml" deployment descriptor file.

Good Luck,
Avi.
 
Georg Joo
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seshu,

I had the same problem. I use the Jonas Srever.

There I have the possibility to make 2(!) JNDI entries.
One (jndi) for the remote home and one (jndi-local) for the local home.
So I can choose the JNDI I need.

Good luck

Georg
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!