• Post Reply Bookmark Topic Watch Topic
  • New Topic

Access EJB deployed in external machine.  RSS feed

Gurumurthy Ramamurthy
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!