jQuery in Action, 3rd edition
The moose likes EJB and other Java EE Technologies and the fly likes Access EJB deployed in external machine. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Access EJB deployed in external machine." Watch "Access EJB deployed in external machine." New topic

Access EJB deployed in external machine.

Gurumurthy Ramamurthy
Ranch Hand

Joined: Feb 13, 2003
Posts: 273
Hi, I have deployed an EJB with JNDI AccountBean in machine, can I call this EJB from another EJB with following entry in DEPLOYMENT DESCRIPTOR?

<jndi-name> jnp://</jndi-name>;

or atleast from stand-alone client, can I access by just giving as above?

I know one method:
If an application wants to access ejb deployed in machine 10.17.24:117:1099 under AccountBean, what is the way to access/how the client would access.

From client program (stand-alone java, or servlet, or jsp or other EJB):

These need to be put and context need to be intantiated as below:

p.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
p.put("java.naming.provider.url", "jnp://localhost:1099");
p.put("java.naming.factory.url.pkgs", "org.jboss.naming rg.jnp.interfaces");

Context ctx = new InitialContext(p);

Then, you can get the bean reference as below:
/* Get a reference to a bean instance, looked up by class name */
Account cart = (Account) ctx.lookup("AccountBean/remote");

Sven Meys

Joined: Feb 13, 2008
Posts: 7
This is how it's done on JBOSS atleast

You need an application-client.xml file in the META-INF directory of your MyClient.jar:


A jndi.properties file in the root of your MyClient.jar:

java.naming.provider.url=jnp://<ip here>:1099
java.naming.factory.url.pkgs=org.jboss.naming.client ...jboss specific
j2ee.clientName=MyClient ...same as display-name

In your application.xml file you need to add:

Running your client jar from a remote computer should now work by doing

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
Object objRef = envCtx.lookup("ejb/MyBean");
MyBeanHome mbh = (MyBeanHome)PortableRemoteObject.narrow(objRef,MyBeanHome.class);
MyBean mb = mbh.create();
I agree. Here's the link: http://aspose.com/file-tools
subject: Access EJB deployed in external machine.
jQuery in Action, 3rd edition