• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem calling EJB by local interfaces  RSS feed

 
Yashar Kalantari
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone

I am new in ejb and I need to call an ejb by its local interfaces and I know that my app and ejb should be in the same VM and they are. when I use remote Interfaces its works just fine but the problem shows up when I try the code below in order to work locally

code:
Context ctx = new InitialContext(this.props);
Object obj = ctx.lookup("ejb/MemberHome");
MemberLocalHome home = (MemberLocalHome) obj;

I am not sure if the code is right. when I run it I get a ClassCastException error. what is wrong?

thanks and regards
yashar
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yashar,
Allow me to suggest the following article (from the ONjava Web site):

Local and Remote EJB Interfaces

Good Luck,
Avi.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37507
552
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yashar,
Note that the JNDI name must be different for the local and remote interfaces. It looks like you are looking up the remote interface and then trying to cast it to a local interface.
 
X. Li
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you modify the Home and Component interfaces so that they entend EJBLocalHome and EJBLocalObject? If you forgot to do it, you might get that exception.
 
Ramesh Krishna
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Context ctx = new InitialContext(this.props);
Object obj = ctx.lookup("local:ejb/ejb/MemberHome");
....
.
.

Try this may be it will work
 
Yashar Kalantari
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again

thanks guys for your valuable advices. the problem is solved. it was my mistake calling a remote interface jndi resource and casting it to a local interface.

cheers
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!