Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.ClassCastException: while creating EJB Object  RSS feed

 
murali jackson
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to create an EJB Object in my servlet Class but it is throwing below error everytime when i invoke the method.



Below is my Code ... Please advise.

 
Rob Spoor
Sheriff
Posts: 21019
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Be Forthright When Cross Posting To Other Sites: https://stackoverflow.com/questions/45529031/ejb-throwing-class-cast-exception-while-creation


Why are you using EJBHome? That's EJB 2.x, and EJB 3.x has been out for years already. Since EJB 3.x is much easier to work with I don't see any reason to use EJB 2.x unless you have a lot of legacy code.

What servlet container are you using? Full-blown JEE containers like Glassfish, JBoss/WildFly or WebLogic allow you to directly inject EJBs into servlets using @EJB.
 
murali jackson
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob,

I am sorry for posting in two sites , generally i wont post in multiple forums. I got stuck on this exception for weeks , i couldn't proceed forward . I will follow the posting rules from now on.

As you asked, in our environment we have application which runs on ejb 2.0 and the server is WAS 6.1 . So I had to use ejb 2.0 only.

Please advise ....
 
Rob Spoor
Sheriff
Posts: 21019
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
murali jackson wrote:I am sorry for posting in two sites , generally i wont post in multiple forums. I got stuck on this exception for weeks , i couldn't proceed forward . I will follow the posting rules from now on.

You can post in two sites, just be upfront about it. Otherwise people will get annoyed if they spend time helping you out, only to find out you already had an answer.

As for your problem, I never did anything with EJB 2.x, so I won't be able to give you much help.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!