Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

ClassCastException for Stateful Bean in JBoss

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
Hi Reza, JaiKiran and AmanDeep,

Finally Its is working.

Thanks a lot.

Thanks & Regards,
Hash
 
rubbery bacon. rubbery tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic