Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JBOSS: Class java.lang.ClassCastException in EJB3.0 lookup

 
Harish Koushik
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I'm trying to invoke a sample HelloBean EJB 3.0 in JBOSS 4.2.2. But getting following error
-------------------ERROR -----------------
11:20:53,187 WARN [RequestProcessor] Unhandled Exception thrown: class java.lang.ClassCastException
11:20:53,187 ERROR [[action]] Servlet.service() for servlet action threw exception
java.lang.ClassCastException: $Proxy63 cannot be cast to examples.session.stateless.Hello
------------------------------------------
EJB jar file deployment was successful.

Trying to lookup in my servlet as shown below, which throws above stated error

Hello hello = (Hello) ctx.lookup("HelloBean/remote");

However, on calling
System.out.println("--->"+ctx.lookup("HelloEJB/remote"));
outputs
--->jboss.j2ee:jar=firstEJB3.jar,name=HelloEJB,service=EJB3

It is unable to cast it to the Remote interface.

Can anyone help me?.

Thanks in advance
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Harish G R" welcome to Javaranch
please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Harish"

Please check your private messages again. Thanks.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably have the EJB interfaces in more than one place. One in the WAR and the other in the JAR. Remove the one in the WAR file.
 
Harish Koushik
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jaikiran,
It worked after removing the ejb remote interface from war folder and my setting the EJB jar in the classpath.

Thanks for your help
Regards
Harish
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic