File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Looking up an EJB 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 "Looking up an EJB" Watch "Looking up an EJB" New topic

Looking up an EJB

Sam Suresh

Joined: Aug 11, 2007
Posts: 1
i am new to j2ee..
i hav one existing enterprise application.
when it is build using ant script it creates an EAR file and gets deployed on the jboss server.
i am writing a standalone java program inside the application only, in eclipse to access one EJB of my deployed application. I hav one framework running for my application.
The interface class of the EJB extends the services of the framework.
i wrote the following code to lookup the ejb say named - xyzEJB, which has a interface class xyz.

xyzEJB myBean;

Properties props = new Properties();
props.put(Context.URL_PKG_PREFIXES,"org.jboss.naming rg.jnp.interfaces");

InitialContext ctx = new InitialContext(props);

//InitialContext ctx = new InitialContext();

Object object = ctx.lookup("xyzEJB");

myBean = (xyzEJB) PortableRemoteObject.narrow( object, xyzEJB.class);
catch (NamingException e){

when i am running this java file i am getting the following error - xyzEJB not bound.

Please let me know if any one can guess wat i m doing wrong....or how can i remove this is error, and access the EJB

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

Welcome to JavaRanch!

Is "xyzEJB" the name of your EJB in the JNDI? (You can check your deployment descriptors to check this.) Usually names look like "ejb/xyzEJB".

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Looking up an EJB
It's not a secret anymore!