users@glassfish.java.net

Remote standalone EJB client

From: Danilo Levantesi <danilo.levantesi_at_gmail.com>
Date: Wed, 29 Oct 2008 12:37:22 +0100

Hi to all,
I'm trying to implement a remote standalone EJB client.
I've read the faq at
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB
and many posts on forums, but I cannot get rid of a little issue...
I've deployed an EJB on Glassfish and written a standalon Java client.
I'm trying to use a no-arg InitialContext() constructor.

First of all, I've to specify the org.omg.CORBA.ORBInitialPort, because it
defaults to 900 and not to 3700.

I run the client with the following command:

java -Dorg.omg.CORBA.ORBInitialHost=localhost\
     -Dorg.omg.CORBA.ORBInitialPort=3700\
     -classpath "/opt/glassfish/appserv-rt.jar:/opt/glassfish/lib/javaee.jar"\
     -jar client.jar

Using this command I obtain:

javax.naming.NameNotFoundException [Root exception is
org.omg.CosNaming.NamingContextPackage.NotFound:
IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
        at
com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:44)
        at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:453)
        at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:492)
        at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:470)
        at javax.naming.InitialContext.lookup(InitialContext.java:351)
        at test.App.main(App.java:26)
Caused by: org.omg.CosNaming.NamingContextPackage.NotFound:
IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
        at
org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:72)
        at
org.omg.CosNaming._NamingContextExtStub.resolve(_NamingContextExtStub.java:406)
        at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:440)

Adding the
property -Djava.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory
(that should be contained in jndi.properties of appserv-rt.jar)
I obtain:

javax.naming.NoInitialContextException: Cannot instantiate class:
com.sun.enterprise.naming.SerialInitContextFactory [Root exception is
java.lang.ClassNotFoundException:
com.sun.enterprise.naming.SerialInitContextFactory]
        at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
        at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
        at javax.naming.InitialContext.init(InitialContext.java:223)
        at javax.naming.InitialContext.<init>(InitialContext.java:175)
        at test.App.main(App.java:15)
Caused by: java.lang.ClassNotFoundException:
com.sun.enterprise.naming.SerialInitContextFactory
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:242)
        at
com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
        at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)

It seems (at least for me) that the classpath is ignored.
Some piece of advice on how to proceed?