• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stuts + EJB = "ClassCastException"!!!

 
pat barry
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried everything thet i know but cant seem to solve the ClassCastException that i receive during execution. Am I using the PortableRemoteObject.narrow() correctly?? Any ideas? Cheers



[ December 30, 2004: Message edited by: pat barry ]
[ December 30, 2004: Message edited by: pat barry ]
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pat,
can you please specify at what line are you getting class cast exception. In fact it will be better if you can provide the complete stacktrace. Also can you provide code for Artist cmp i.e. code for its home, remote and bean class.

thanks
 
pat barry
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hope this helps, cheers!



AtristHome.java



Artist.java (remote)



ArtistBean.java

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This looks like the problem. The parameter to lookup() is supposed to be the JNDI name.
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:

This looks like the problem. The parameter to lookup() is supposed to be the JNDI name.


Jeanne, i believe if the JNDI name is wrong than the application should throw javax.naming.NamingException rather than the ClassCastException.

May be some other bean is associated with the name "ArtistBean" in the deployment descriptor. May be by displaying the name of the class after the lookup should make the picture more clear.

System.out.println(obj.getClass().getName());
 
pat barry
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all the input guys! Your both right. It seems to be a problem with my lookup().

I get this warning when I start my server:



So my bean already exists. How can I correct this?

Prakash, I did the system.out on my obj and got $Proxy51
Any ideas?
Cheers for the help, well appreciated!!
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prakash, I did the system.out on my obj and got $Proxy51


My mistake, actually on performing lookup we get instance of container generated stub class which implements the home interface.



Depends On Me: , ObjectName: jboss.j2ee:module=MyStoreMgr.jar,service=EjbModule
state: FAILED
I Depend On:
Depends On Me: javax.management.InstanceAlreadyExistsException: jboss.j2ee:jndiName=ArtistBean,service=EJB


Appears that two beans are registered with the same jndi name, you should check ejb-jar.xml file for that. Possibility of some other ear file having an ejb with this jndi name can not be ruled out as well, so you have to check other ear files also (if exists).

I hope this helps
 
pat barry
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prakash, you GENIUS, I got it working. Cheers for the help!

I had two beans with the same JNDI name, it was from an old project! Deleted it from my server deploy folder and from my environment!

Cheers for the help everyone!
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic