• 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

ClassCastException for Stateful Bean in JBoss

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Reza and other Ranchers,

I am facing some issue in Stateful Session Bean in JBoss.

This is my SessionBean code




The following Code in my client calls the bean



I get the following error.
java.lang.ClassCastException: $Proxy169

I also checked the classpath and everything and they seems to be fine.
Also if I change the @Stateful to @Stateless, it works fine

Is this the issue with the JBoss4.2.2GA version.

Your Help would be appreciated.

Thanks in advance.

Regerds,
Hash
 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try to change your Bean code to like this-

@Stateful(name = "SampleStatefulEJBA", mappedName="java:comp/env/SampleStatefulEJBA")
 
hashmukh punamia
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI AmanDeep,

I am still getting the same Error.

java.lang.ClassCastException: $Proxy71

any other solutions for this issue

Thanks,
Hash
 
author
Posts: 580
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hash,

This does look like a class-path issue. I would look closely to see if you have multiple copies of any class/interface in the classpath. If so, you'll need to remove them and set module depenencies correctly.

Best regards,
Reza
 
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
hashmukh,

As Reza mentioned, check whether you are packaging the bean interfaces in more than one place - one in jar and one in war. If so, then remove it from the war and let it remain in the jar.

Also if I change the @Stateful to @Stateless, it works fine



That's interesting. Which JDK version do you use? And do you use any IDE (like NetBeans) with JBoss? I remember something similar with NetBeans and JBoss with Java 1.6
 
hashmukh punamia
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Reza and Pai,

Thanks for your quick reply.

I am using Netbeans6.1RC2 to create a independant EJB module with the stateless bean code as shown in the above message. My EJB module only consists of a sample Bean and a the Bean Interface.
Then I deploy the ejb module in JBoss4.2.2GA.

Now I create a seperate web application project to which I have added this ejb jar file to my project lib.
I am importing the package into my JSP and just doing a lookup for the same.

But I am getting java.lang.ClassCastException: $Proxy108

Thanks in advance

Thanks,
Hash
 
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
Hash,

You cannot copy the ejb-jar file directly. You must properly reference it as a Java EE module via manifest class path dependency. Again, feel free to take a look at our JBoss code examples.

Best regards,
Reza
 
hashmukh punamia
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Reza, JaiKiran and AmanDeep,

Finally Its is working.

Thanks a lot.

Thanks & Regards,
Hash
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic