File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
tyler piter
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 580
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
tyler piter
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reza,

Thanks!
it works now by follow your instruction. it seems jvm is confused by two same classes.
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic