You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by toby cabot <to...@caboteria.org> on 2004/07/15 01:23:58 UTC

EJB lookup in JNDI?

Hi Folks,

With Gianny's fix for EJB deployment (thanks!) I can now run the
deploy tool on modules/j2ee/target/test-ejb-jar.jar and start up the
server and everything looks good, i.e. no stack traces.  Now I'm
trying to call the EJB from a unit test outside Geronimo but I'm stuck
looking it up.  I cribbed some JNDI parameters from one of the unit
tests and I can connect to JNDI but when I list the entries in the ""
context all I find is "JMXConnector".  I seem to get the same result
no matter what I pass to InitialContext.list().

Here are my properties:
  <target name="test-geronimo" description="Run the unit tests that depend on the build having been deployed in Geronimo.">
    <java classname="skeleton.ServerUnitTest" failonerror="true" classpathref="testpath">
      <sysproperty   key="java.naming.factory.initial" value="com.sun.jndi.rmi.registry.RegistryContextFactory" />
      <sysproperty   key="java.naming.factory.url.pkgs" value="org.apache.geronimo.naming" />
      <sysproperty   key="java.naming.provider.url" value="rmi://localhost:1099"/>
    </java>
   </target>

The EJB's entry in openejb-jar.xml is:
    <enterprise-beans>
        <session>
            <ejb-name>SimpleStatelessSession</ejb-name>
            <jndi-name>client/test/simple/SimpleStatelessSessionHome</jndi-name>
        </session>
    </enterprise-beans>

I guess I should ask first if this functionality (i.e. remote JNDI and
EJB calls) is even implemented, maybe I'm trying something that's not
built yet.  If it's supposed to work I'd welcome any tips people can
offer.

Regards,
Toby

Re: EJB lookup in JNDI? (that works)

Posted by toby cabot <to...@caboteria.org>.
On Thu, Jul 15, 2004 at 11:47:58AM -0500, David Blevins wrote:
> Is it complaining when they are not there or just when they are
> specified in the system properties?

It complains if they're not there; and if they're set in system
properties it doesn't see them (and complains).  It works if they're
set in a Properties that's passed to the InitialContext constructor.

Thanks,
Toby

Re: EJB lookup in JNDI? (that works)

Posted by David Blevins <da...@visi.com>.
On Thu, Jul 15, 2004 at 12:27:50PM -0400, toby cabot wrote:

>         p.put("java.naming.security.principal", "myuser");
>         p.put("java.naming.security.credentials", "mypass");

> For some reason I can't pass the java.naming.security.principal
> property in from the system properties, openEJB complains that it's
> null, but it works fine if I set it in Java.

Hey Toby,

Is it complaining when they are not there or just when they are
specified in the system properties?

The code used to force you to specify a principal and credentials, but
since it isn't yet used I thought I dissabled that.  Let me know and
I'll fix it.

-David

Re: EJB lookup in JNDI? (that works)

Posted by toby cabot <to...@caboteria.org>.
Thanks, Dain.  That's the ticket.  

For the benefit of archive-reading newbies (like me!), here's the
client-side code:

    InitialContext newInitialContext() throws NamingException {
        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");
        
        return new InitialContext(p);
    }

For some reason I can't pass the java.naming.security.principal
property in from the system properties, openEJB complains that it's
null, but it works fine if I set it in Java.

Thanks again,
Toby

Re: EJB lookup in JNDI?

Posted by Dain Sundstrom <da...@coredevelopers.net>.
On Jul 14, 2004, at 5:03 PM, Jeremy Boynes wrote:

> toby cabot wrote:
>
>> I guess I should ask first if this functionality (i.e. remote JNDI and
>> EJB calls) is even implemented, maybe I'm trying something that's not
>> built yet.  If it's supposed to work I'd welcome any tips people can
>> offer.
>
> I don't believe it's there yet.

It does, but geronimo and openejb currently have separate jndi 
providers.  If you use these settings instead, it should work:

<sysproperty
     key="java.naming.factory.initial"
     value="org.openejb.client.RemoteInitialContextFactory"/>

<sysproperty
     key="java.naming.provider.url"
     value="25.14.3.92:4201"/>


-dain


Re: EJB lookup in JNDI?

Posted by Jeremy Boynes <jb...@gluecode.com>.
toby cabot wrote:

> 
> I guess I should ask first if this functionality (i.e. remote JNDI and
> EJB calls) is even implemented, maybe I'm trying something that's not
> built yet.  If it's supposed to work I'd welcome any tips people can
> offer.
> 

I don't believe it's there yet.

--
Jeremy