• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Harish"

Please check your private messages again. Thanks.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic