| Author |
Looking up an EJB
|
Sam Suresh
Greenhorn
Joined: Aug 11, 2007
Posts: 1
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26215
|
|
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".
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: Looking up an EJB
|
|
|