Just a note on narrowing. The spec says you should narrow, but when using the org.openejb.client.RemoteInitialContextFactory, you never have to. We use dynamic proxies which don't require narrowing.

-David

On Jul 13, 2006, at 10:05 PM, Lasantha Ranaweera wrote:

Hi Isuru,

It looks you are trying to access EJB from outside the JVM of application server. So that is why David says it should be a j2ee client (client residing in the same JVM of the app sever) to use "java:comp" like JNDI name . Also note you have to narrow down the object before using it.

Following is a remotely refer EJB client that worked for me. Hope this will help.

        Properties props = new Properties();

props.setProperty ("java.naming.factory.initial","org.openejb.client.RemoteInitialContex tFactory");
     props.setProperty("java.naming.provider.url", "localhost:4201");
     props.setProperty("java.naming.security.principal","system");
     props.setProperty("java.naming.security.credentials","manager");

javax.naming.InitialContext initialContext = new javax.naming.InitialContext(props);
     Object objRef = initialContext.lookup("com.test.ejb.HelloBean");

HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(objRef, HelloHome.class);
     Hello hello = home.create();

     hello.sayHello();



Thanks,
Lasantha Ranaweera
Senior Software Engineer,
Lanka Software Foundation,
Sri Lanka.

Isuru Samaraweera wrote:
Hi David,

Its a J2EE client I am using.Here is the client code

 Hashtable ht=new Hashtable();
ht.put ("java.naming.factory.initial","org.openejb.client.RemoteInitialConte xtFactory");
  ht.put("java.naming.provider.url","127.0.0.1:4201");
  ht.put("java.naming.security.principal","system");
  ht.put("java.naming.security.credentials","manager");

  try
  {
  Context context = new InitialContext(ht);
  StoreHome home =null;
   home=(StoreHome)context.lookup("java:comp/env/ejb/StoreLocal");

 Store store = home.create();
  store.storeMax();
  }

Thank You,
regards,
Isuru
David Jencks <[EMAIL PROTECTED]> wrote:
It looks to me as if you are using a non-j2ee app client but trying to use jndi as if it is a j2ee app client. From a non-j2ee- app-client you have to look up whatever you specify as jndi-name in the openejb config, and you have to use the proprietary jndi configuration for openejb jndi. In particular you shouldn't be looking in java:comp unless you have a j2ee client. Can you clarify what you are trying to do?

thanks
david jencks

On Jul 11, 2006, at 11:14 AM, Isuru Samaraweera wrote:

Hi All,

I have successfully deployed an application with session bean in geronimo1.1 However when I try to lookup the session bean from a client application,jndi name (java:comp/env/ejb/StoreLocal) was not bound.In the geronimoserver console following error was displayed.

23:09:13,812 ERROR [JndiRequestHandler] JNDI request error
java.lang.IllegalArgumentException: uri path must be in the form [groupId]/[arti
factId]/[version]/[type] : /java:comp/env/ejb/StoreLocal
at org.apache.geronimo.gbean.AbstractNameQuery.<init> (AbstractNameQuery.
java:104)
at org.openejb.ContainerIndex.getContainerIndex (ContainerIndex.java:208) at org.openejb.ContainerIndex$$FastClassByCGLIB$ $6674ccb6.invoke(<genera
ted>)
at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java: 53) at org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke (FastMethod
Invoker.java:38)
at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke (GBeanOperatio
n.java:122)
at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke (GBeanInstance.
java:817)
at org.apache.geronimo.gbean.runtime.RawInvoker.invoke (RawInvoker.java:5
7)
at org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke (RawOperat
ionInvoker.java:35)
at org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept (Pro
xyMethodInterceptor.java:96)
at org.openejb.ContainerIndex$$EnhancerByCGLIB$ $4d03a4f9.getContainerInd
ex(<generated>)
at org.openejb.server.ejbd.JndiRequestHandler.doLookup (JndiRequestHandle
r.java:178)
at org.openejb.server.ejbd.JndiRequestHandler.processRequest (JndiRequest
Handler.java:115)
at org.openejb.server.ejbd.EjbDaemon.service (EjbDaemon.java:154) at org.openejb.server.ejbd.EjbServer.service (EjbServer.java:87) at org.openejb.server.ejbd.EjbServer$$FastClassByCGLIB$ $d379d2ff.invoke(
<generated>)
at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java: 53) at org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke (FastMethod
Invoker.java:38)
at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke (GBeanOperatio
n.java:122)
at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke (GBeanInstance.
java:817)
at org.apache.geronimo.gbean.runtime.RawInvoker.invoke (RawInvoker.java:5
7)
at org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke (RawOperat
ionInvoker.java:35)
at org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept (Pro
xyMethodInterceptor.java:96)
at org.activeio.xnet.ServerService$$EnhancerByCGLIB$ $9ba58c2.service(<ge
nerated>)
        at org.activeio.xnet.ServicePool$2.run(ServicePool.java:67)
        at org.activeio.xnet.ServicePool$3.run(ServicePool.java:90)
at org.apache.geronimo.pool.ThreadPool$1.run (ThreadPool.java:172) at org.apache.geronimo.pool.ThreadPool $ContextClassLoaderRunnable.run(Th
readPool.java:289)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor $Worker.run(Unknown So
urce)
        at java.lang.Thread.run(Thread.java:595)

I have put following jar files in the classpath.

geronimo-kernel-1.1-SNAPSHOT.jar
geronimo-spec-j2ee-1.4-rc4.jar
openejb-core-2.0-SNAPSHOT.jar
cglib-nodep-2.1.jar
geronimo-security-1.1-SNAPSHOT.jar

Can anybody suggest a solution for this problem?

Thank You,
regards,
Isuru

Want to be your own boss? Learn how on Yahoo! Small Business.



Yahoo! Music Unlimited - Access over 1 million songs. Try it free.


Reply via email to