This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClassCastException for Stateful Bean in JBoss

 
hashmukh punamia
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
 
Amandeep Singh
Ranch Hand
Posts: 850
  • 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
 
Reza Rahman
author
Ranch Hand
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
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
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
Ranch Hand
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic