Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

classCastException coming from an ejb  RSS feed

 
alexandre russel
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an local ejb foo. I packed it into a jar and deployed it to JBOSS.
I can test it with cactus. Take a test file, packed it into a jar, add the cactus redirector and the code:
FooHome h = (FooHome) ctx.lookUp("ejb/Foo");
will work.

Now if I create a war file, with in the lib my client-ejb.jar, and I do:
FooHome h = (FooHome) ctx.lookUp("ejb/Foo")
I got a classCastException: $proxy45.
However, if I look at the jmx-console I do have $proxy45 with ejb/Foo that reference FooHome ...
If anyone could just give a hint on what I am doing wrong?
I think it may have to do with classLoader but don't get where or why.
thanks in advance,
alex
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting that the lookup itself isn't failing. You might want to temporarily remove the cast and use reflection to tell you the interfaces and that proxy is implementing, just in case you spot something that clearly wasn't what you would have expected.

You didn't mention an ear, so might turn out to be something related to the fact that you are using a war to talk to an ejb, but both the war and ejb aren't in the same ear. You are allowed to do that, but you can run into the odd wrinkle or two. If it were WebLogic or any other container with a conformant class loader hierarchy, I'd expect you were just missing something from the war's classpath. With JBoss's goofy universal class loader repository things get much more subtle to track down.

If you stay stuck I'd recommend assembling an ear with all of these together and see what happens.
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if your case is related to:
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=66394

Have a look at the comment by "darranl Posted: Fri Jul 15, 2005 07:51 AM" on that topic
 
alexandre russel
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Reid and jaikiran.
I finaly found the problem. I was using a small helper class and my ejb was sending an array of that helper class. I check 10000 times that ejb and war used the "same" ejb-client and they did, but ejb and war were using different helper class.
thanks again for taking the time to reply.
alex
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!