aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes ClassCastException when casting to home interface    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ClassCastException when casting to home interface    " Watch "ClassCastException when casting to home interface    " New topic
Author

ClassCastException when casting to home interface

Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 689
Hello,

I have the following code on my Delegate class:


I get a ClassCastException on





Debugging code in Eclipse I see that "initContext.lookup(JNDIName)" is an object type "_RecursoHome_Stub". So the error should't happen, isn't it?


I use Sun One Appication Server 7, Struts and EJB. The application structure is the same as it was in JBoss, on which worked fine.

Follwing the contents of ejb-jar.xml, sun-ejb-jar.xml, sun-web.xml and web.xml:

ejb-jar.xml:



sun-ejb-jar.xml:




sun-web.xml:

web.xml:




Thanks in advance


SCEA 5 (part 1), SCBCD, SCWCD, SCJP, CLP, CLS
Ashwini Kumar Sharma
Greenhorn

Joined: Jun 02, 2006
Posts: 2
Hi,

I am not sure if it works..but try doing a explicit type cast of the object returned by initialContext into your Remote Home Interface.

User PortableRemoteObject.narrow() and check if it still gives the same exception.

Ashwini
Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 689
Hello

Tried to do:



But the ClassCastException still happens. Any other idea?


Following the complete class code:

[ June 07, 2006: Message edited by: Oscar Kinto ]
Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 689
I've solved the problem! The packaging structure used in JBoss does not work at SunOne.
I put the remote and bean classes in the same package (ejb), and put this at ejb jar.
 
jQuery in Action, 2nd edition
 
subject: ClassCastException when casting to home interface