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 Can we use Entity bean(EJB3.0) in struts2.0? 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 "Can we use Entity bean(EJB3.0) in struts2.0?" Watch "Can we use Entity bean(EJB3.0) in struts2.0?" New topic
Author

Can we use Entity bean(EJB3.0) in struts2.0?

tyler piter
Greenhorn

Joined: Feb 11, 2009
Posts: 2
Recently i take a try:

EntityBean: User.java
SessionBean: UserDao.java
Struts 2 Action: LoginAction.java

In LoginAction.java, i wrote:

User user=(User)UserDao.findUser(username,password);

Then, i got:

java.lang.ClassCastException: can't cast com.xx.xx.entity.User to com.xx.xx.entity.User.

How can i fix this?

Reza Rahman
author
Ranch Hand

Joined: Feb 01, 2005
Posts: 580
    
    5
Tyler,

Looks like a class-loading issue. Do you have duplicate (iedntical) classes in the WAR and EJB-JAR? If so, you need to eliminate that.

Thanks,
Reza


Independent Consultant — Author, EJB 3 in Action — Expert Group Member, Java EE 6 and EJB 3.1
tyler piter
Greenhorn

Joined: Feb 11, 2009
Posts: 2
Reza,

Thanks!
it works now by follow your instruction. it seems jvm is confused by two same classes.
Reza Rahman
author
Ranch Hand

Joined: Feb 01, 2005
Posts: 580
    
    5
Tyler,

Just so you are aware, we talk about packaging and classloading for Java EE 5 applications in EJB 3 in Action. That being said, most readers seem to gloss over these important parts :-(.

Regards,
Reza
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can we use Entity bean(EJB3.0) in struts2.0?
 
Similar Threads
Login then Retrieval
Problem with LoginAction.java
displaying user eneterd value on jsp page
struts very important question to me?
Limitations on use of html:errors