You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Sai Arunachalam <sa...@gmail.com> on 2004/08/18 16:02:59 UTC

Geronimo JNDI properties

Hi,
     I am trying to run a stateless session HelloWorld example that
comes with MasteringEJB2 (it is meant for WebLogic 6.1) on Geronimo.
The HelloWorld.jar gets deployed on the server and I am able to start
the server with the appropriate configId but ain't able to run the
client. I am getting the following exception:

Exception in thread "main" javax.naming.NameNotFoundException: HelloHome
        at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:90)
        at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:98)
        at javax.naming.InitialContext.lookup(InitialContext.java:347)
        at examples.HelloClient.main(HelloClient.java:36)

My openejb-jar.xml is as follows:
------------------------------------------------

<?xml version="1.0"?>

<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar"
configId="your/domain/name/HelloWorld3"
parentId="org/apache/geronimo/Server">

<enterprise-beans>
        <session>
        <ejb-name>Hello</ejb-name>
        <jndi-name>HelloHome</jndi-name>
        <local-jndi-name>HelloLocalHome</local-jndi-name>
        </session>
</enterprise-beans>

</openejb-jar>

The original command given in the example to run the client was as follows:

java -Djava.security.policy=../java.policy
-Djava.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
-Djava.naming.provider.url=t3://localhost:7001 examples.HelloClient


java.policy is the following two lines:
grant {^M
        permission java.security.AllPermission;^M
        permission java.net.SocketPermission "*","listen,accept,connect";^M
};

I give the following command:

java -classpath ./Hello.jar:/home/TU1/j2ee/j2sdkee1.3.1/lib/j2ee.jar
-Djava.naming.factory.initial=com.sun.jndi.rmi.registry.RegistryContextFactory
-Djava.naming.factory.url.pkgs=org.apache.geronimo.naming
-Djava.naming.provider.url=rmi://localhost examples.HelloClient

Am I wrong with JNDI properties for Geronimo or is it something else?

Thanks in help,
Sai

Re: Geronimo JNDI properties

Posted by Sai Arunachalam <sa...@gmail.com>.
Thanks Toby,
     That did it. And that ClassNotFoundException note helped too :)
Regards,
Sai

Re: Geronimo JNDI properties

Posted by toby cabot <to...@caboteria.org>.
On Wed, Aug 18, 2004 at 11:40:43PM +0530, Sai Arunachalam wrote:
> Exception in thread "main" javax.naming.NoInitialContextException:
> Cannot instantiate class:
> org.openejb.client.RemoteInitialContextFactory [Root exception is
> java.lang.ClassNotFoundException:
> org.openejb.client.RemoteInitialContextFactory]

That's progress.  It looks as if the properties are OK but now you
don't have all of the jars that you need on the classpath.  Here's a
fragment that I use:

java -classpath lib/geronimo/geronimo-security-1.0-SNAPSHOT.jar:lib/openejb/openejb-core-2.0-SNAPSHOT.jar:lib/openejb/cglib-full-2.0.jar:lib/sun/j2ee.jar

You might not need Sun's j2ee jar, I might have that left over from
some other stuff I was doing.  RemoteInitialContextFactory is in
openejb-core-2.0-SNAPSHOT.jar, and I'm pretty sure that you need cglib
as well.  You can experiment and figure out what works for you.  Hint:
if you get a ClassNotFoundException then you need to start running
"jar tv" on the jars that you've got to see which one has the class
that you're looking for.  Put that one on the classpath and try again.

You're almost there.


Re: Geronimo JNDI properties

Posted by Sai Arunachalam <sa...@gmail.com>.
Hi Toby (and all),
      I tried using the same properties given on the OpenEJB page with
all the p.put statements embedded in the client program itself. It
doesn't work then too and gives the following exception.

Exception in thread "main" 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 examples.HelloClient.main(HelloClient.java:35)
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

Besides, I just wanted to say that the HelloWorld example that I am
trying to run on Geronimo isn't the one that is given on the OpenEJB
HelloWorld page. I am referring to a program that I downloaded
alongwith Mastering EJB2 (by Ed Roman et al.) from TheServerSide.com.
It was meant to be run on WebLogic 6.1.

Any help would be valuable.

Thanks,
Sai

Re: Geronimo JNDI properties

Posted by toby cabot <to...@caboteria.org>.
On Wed, Aug 25, 2004 at 11:13:45AM +0200, Jacek Laskowski wrote:
> Just saw the thread, and I'm concerned with the system properties and 
> the JNDI factories. Would you send me an example that proves it?

Hi Jacek,

Thanks for the help.  Here's the story:

If I set up a simple EJB (like the ones used in the OpenEJB remote
tests) and call it remotely it works fine if I specify the 4
parameters needed in code

        Properties p = new Properties();
        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", "myuser");
        p.put("java.naming.security.credentials", "mypass");

And it also works if I put the first two on the command line

        Properties p = new Properties();
        p.put("java.naming.security.principal", "myuser");
        p.put("java.naming.security.credentials", "mypass");

$ java -Djava.naming.factory.initial=org.openejb.client.RemoteInitialContextFactory -Djava.naming.provider.url=127.0.0.1:4201 etc...

but if I try to put the java.naming.security.principal on the command
line

        Properties p = new Properties();
        p.put("java.naming.security.credentials", "mypass");

$ java -Djava.naming.factory.initial=org.openejb.client.RemoteInitialContextFactory -Djava.naming.provider.url=127.0.0.1:4201  -Djava.naming.security.principal=myuser etc...

then I get

javax.naming.ConfigurationException: Context property cannot be null: java.naming.security.principal
        at org.openejb.client.JNDIContext.getInitialContext(JNDIContext.java:163)
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
        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 g6o.ServerUnitTest.newOpenEJBInitialContext(ServerUnitTest.java:50)
        at g6o.ServerUnitTest.findStatelessSessionBean(ServerUnitTest.java:118)
        at g6o.ServerUnitTest.testPing(ServerUnitTest.java:95)

I thought that perhaps junit wasn't passing the properties through,
but since the first two get propagated I think that's not likely to be
the problem.

If you'd like me to send you code please let me know.

Regards,
Toby

Re: Geronimo JNDI properties

Posted by Jacek Laskowski <jl...@apache.org>.
toby cabot wrote:

> My understanding is that at the moment OpenEJB uses its own JNDI
> provider so you can get the property values, etc from
> http://www.openejb.org/hello-world.html .  The only caveat that I'd
> add is that it doesn't look as if OpenEJB picks up the properties from
> the system properties so you need to specify them explicitly (like
> they do on that page).

Hi,

Just saw the thread, and I'm concerned with the system properties and 
the JNDI factories. Would you send me an example that proves it?

OpenEJB provides two InitialContext factories: the Local and Remote one 
and they (try to) work as mandated by the JNDI spec. I must admit I'm 
really puzzled as to why it didn't work with the system properties. The 
example would help a lot.

Best,
Jacek


Re: Geronimo JNDI properties

Posted by toby cabot <to...@caboteria.org>.
On Wed, Aug 18, 2004 at 07:32:59PM +0530, Sai Arunachalam wrote:
> Hi,
>      I am trying to run a stateless session HelloWorld example that
> comes with MasteringEJB2 (it is meant for WebLogic 6.1) on Geronimo.

My understanding is that at the moment OpenEJB uses its own JNDI
provider so you can get the property values, etc from
http://www.openejb.org/hello-world.html .  The only caveat that I'd
add is that it doesn't look as if OpenEJB picks up the properties from
the system properties so you need to specify them explicitly (like
they do on that page).

> The HelloWorld.jar gets deployed on the server and I am able to start
> the server with the appropriate configId but ain't able to run the
> client. I am getting the following exception:
> 
> Exception in thread "main" javax.naming.NameNotFoundException: HelloHome

This looks like a JNDI error so I'd check the properties from the
above page and try again.