Two Laptop Bag*
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
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
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
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
Limitations on use of html:errors
Login then Retrieval
Problem with LoginAction.java
displaying user eneterd value on jsp page
struts very important question to me?