try this:

Properties p = new Properties();
p.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
p.put("java.naming.provider.url", "ejbd://localhost:4201");
// user and pass optional
p.put("", "myuser");
p.put("", "mypass");

InitialContext ctx = new InitialContext(p);

MyBean myBean = (MyBean) ctx.lookup("MyBeanRemote");

On Mon, Jan 17, 2011 at 6:12 PM, sanjay kumar <> wrote:
@devid ...
   I have already tried this. Any more suggestion.

On Mon, Jan 17, 2011 at 2:01 PM, David Jencks <> wrote:
Hi Sanjay,

IIUC you are trying to get to the ejb from a javaee app that is not part of the app containing the ejb?

(if they are part of the same app your can use an ejb-link IIRC)

I think you can either include a properties object in new InitialContext(properties) with the openejb jndi properties to use openejb jndi directly or include an ejb-ref or @EJB and use some configuration in the geronimo plan to refer to the ejb in the other app.

hope this helps... it is not a complete answer but might point you in a useful direction.

david jencks
On Jan 17, 2011, at 12:03 AM, sanjay kumar wrote:

Hi all,
   I am trying to call an EJB from a client that is itself deployed in same server i.e Geronimo 2.2. But I am getting Exception.
The code to call EJB is:
try {
            Context icontext=new InitialContext();
             obj = icontext.lookup("ejbName");

And I am getting exception as:

javax.naming.NameNotFoundException: ejbName
    at org.apache.xbean.naming.context.AbstractContext.lookup(
    at org.apache.xbean.naming.context.AbstractContext.lookup(
    at javax.naming.InitialContext.lookup(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav

I have @Local and @Remote annotations in the EJB. And it works properly when called from external client. I have tried iContext.lookup("ejb/beanrefname")
as well as all these:

Can anyone give me any idea how to accomplish this.?
How to lookup an EJB from client code that resides in same server.?
and all that...
Sanjay Kumar
Java Developer

Sanjay Kumar
Java Developer