GeeCON Prague 2014*
The moose likes EJB and other Java EE Technologies and the fly likes JBOSS: Class java.lang.ClassCastException in EJB3.0 lookup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JBOSS: Class java.lang.ClassCastException in EJB3.0 lookup" Watch "JBOSS: Class java.lang.ClassCastException in EJB3.0 lookup" New topic
Author

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

Harish Koushik
Greenhorn

Joined: Dec 19, 2008
Posts: 2
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

Joined: Jun 06, 2007
Posts: 2716
    
    6

"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.


SCJP, SCWCD.
|Asking Good Questions|
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10141
    
165

"Harish"

Please check your private messages again. Thanks.


[My Blog] [JavaRanch Journal]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10141
    
165

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

Joined: Dec 19, 2008
Posts: 2
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
 
GeeCON Prague 2014
 
subject: JBOSS: Class java.lang.ClassCastException in EJB3.0 lookup