| 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: 559
|
|
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: 559
|
|
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
|
 |
 |
|
|
subject: Can we use Entity bean(EJB3.0) in struts2.0?
|
|
|