I was trying to follow the hello bean example.  I have
openejb 0.9.2 deployed with Tomcat 5.0.28 On Win2k
with Sun JDK 1.4.2.  I have tested the openejb config
Ok and the bean is deployed OK with the "Hello" JNDI
name.  This is running on my local desktop machine, so
I am using the 127.0.0.1 IP.

When I try to invoke it from a app executing in my
Eclipse debugger, I get the error:

javax.naming.NoInitialContextException: Cannot
instantiate class:
org.openejb.client.RemoteInitialContextFactory [Root
exception is java.lang.ClassNotFoundException:
org.openejb.client.RemoteInitialContextFactory]
        at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:652)
        at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
        at
javax.naming.InitialContext.init(InitialContext.java:219)
        at
javax.naming.InitialContext.<init>(InitialContext.java:195)
        at HelloWorld.main(HelloWorld.java:27)
Caused by: java.lang.ClassNotFoundException:
org.openejb.client.RemoteInitialContextFactory
        at
java.net.URLClassLoader$1.run(URLClassLoader.java:199)
        at java.security.AccessController.doPrivileged(Native
Method)
        at
java.net.URLClassLoader.findClass(URLClassLoader.java:187)
        at
java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
        at
java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:219)
        at
com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
        at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
        ... 4 more

My client app code is:

import java.util.Properties;

import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;

import org.acme.HelloHome;
import org.acme.HelloObject;

public class HelloWorld {

    public static void main(String args[]) {
        try {

            Properties p = new Properties();

            //The JNDI properties you set depend
            //on which server you are using.
            //These properties are for the Remote
Server.
            p.put("java.naming.factory.initial",
                   
"org.openejb.client.RemoteInitialContextFactory");
            p.put("java.naming.provider.url",
"127.0.0.1:4201");
            p.put("java.naming.security.principal",
"admin");
            p.put("java.naming.security.credentials",
"password");

            //Now use those properties to create
            //a JNDI InitialContext with the server.
            InitialContext ctx = new
InitialContext(p);

            //Lookup the bean using it's deployment id
            Object obj = ctx.lookup("/Hello");

            //Be good and use RMI remote object
narrowing
            //as required by the EJB specification.
            HelloHome ejbHome = (HelloHome)
PortableRemoteObject.narrow(obj,
                    HelloHome.class);

            //Use the HelloHome to create a
HelloObject
            HelloObject ejbObject = ejbHome.create();

            //The part we've all been wainting for...
            String message = ejbObject.sayHello();

            //A drum roll please.
            System.out.println(message);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Any ideas on what I did wrong?

Regards,

Jimmy Ray




                
__________________________________ 
Discover Yahoo! 
Have fun online with music videos, cool games, IM and more. Check it out! 
http://discover.yahoo.com/online.html

Reply via email to