• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Class Cast Exception

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic