Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Looking up an EJB

 
Sam Suresh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
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.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
props.put(Context.URL_PKG_PREFIXES,"org.jboss.naming rg.jnp.interfaces");
props.put(Context.PROVIDER_URL,"jnp://localhost:1099");

try{
InitialContext ctx = new InitialContext(props);

//InitialContext ctx = new InitialContext();

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

myBean = (xyzEJB) PortableRemoteObject.narrow( object, xyzEJB.class);
}
catch (NamingException e){
System.out.println("Error"+e.getMessage());
}

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

TIA/Sam
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sam,
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".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic