• Post Reply Bookmark Topic Watch Topic
  • New Topic

class casting with ejb  RSS feed

 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an EJB client:



HelloWorld is an implementation class of HelloWorldRemote.

I have class cast exception that wrapper cannot be cast on HelloWorld.

When I use:
HelloWorldRemote hw = (HelloWorldRemote) ctx.lookup("ejb/HelloWorldBean");
everything runs flawlessly.

Can someone describe me this situation?
 
Bartender
Posts: 2289
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Lucas.

Well champ, can you show us the code of HelloWorldBean, HelloWorld and HelloWorldRemote? Can you show us the exception's stack trace?
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Unless the client is a local client to the EJB and uses a no-interface view of the EJB, you cannot use the implementation class when casting the result of the lookup.
In your case, what I can tell is:
1. The client is not a local client of the EJB, since it seems to be executing in another JVM than the EJB.
2. The EJB implements a remote interface. If you haven't explicitly annotated the EJB implementation class with @LocalBean, then there is no local view of the EJB.
Best wishes!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!