This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Stuts + EJB = Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Stuts + EJB = "ClassCastException"!!!" Watch "Stuts + EJB = "ClassCastException"!!!" New topic
Author

Stuts + EJB = "ClassCastException"!!!

pat barry
Greenhorn

Joined: Dec 29, 2004
Posts: 9
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

Joined: Sep 28, 2002
Posts: 452
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


Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
pat barry
Greenhorn

Joined: Dec 29, 2004
Posts: 9
Hope this helps, cheers!



AtristHome.java



Artist.java (remote)



ArtistBean.java

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150


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


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
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

Joined: Dec 29, 2004
Posts: 9
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

Joined: Sep 28, 2002
Posts: 452
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

Joined: Dec 29, 2004
Posts: 9
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

Joined: Sep 28, 2002
Posts: 452
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Stuts + EJB = "ClassCastException"!!!
 
Similar Threads
calling ejb on another machine on OC4J hangs
Calling EJB from POJO class
EJB problem
Need Help With JBoss/JMS/JNDI/MQSeries
Calling ejb on OC4J application server