• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
author
Posts: 580
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 580
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic