Q
Problem solve Get help with specific problems with your technologies, process and projects.

Using JNDI lookup to find an EJBLocalHome interface

What will happen if I try to use JNDI lookup to find an EJBLocalHome interface which is not running on the same machine as my client? Will the cast fail? Will I get an exception?
Performing a JNDI lookup on a remote EJB should always be followed by a call to PortableRemote.narrow(lookupObj, actualHomeClass) method to convert the object returned from a lookup to the EJBHome object. This is a requirement of the EJB specification in order to maintain CORBA compatibility.

The EJBLocalHome interface is meant to be used for EJBs in the same JVM as the caller. Since both the caller and the EJB are in the same JVM, you can simply cast the object returned from the JNDI lookup to an EJBLocalHome object.

The following link illustrates this concept very effectively:
http://java.sun.com/blueprints/patterns/ServiceLocator.html

Dig Deeper on Topics Archive

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchSoftwareQuality

SearchAWS

SearchCloudComputing

TheServerSide.com

Close