Title: RE: Inconsistent EJB JNDI Locations
i'm reasonably new to this also, so i may be wrong!
 
i have the application-client.xml in a META_INF directory which is beside my client application, so i think the client application InitialContext reads this file, it seems to work for me anyway..
 
hope this helps..
 
----- Original Message -----
Sent: Tuesday, March 13, 2001 8:41 PM
Subject: RE: Inconsistent EJB JNDI Locations

A related point? (I'm new to this and a bit confused)

Purely as an academic exercise I tried to access my EJB from an external application.
The Orion documentation on this is sparse to non-existant :(

What ended up working for me is the following:

1. Write an application-client.xml (undocumented, but I figured it out from another example)
<application-client>
        <display-name>PLJB User</display-name>
        <ejb-ref>
                <ejb-ref-name>PLJB_User</ejb-ref-name>
                <ejb-ref-type>Entity</ejb-ref-type>
                <home>com.hotjobs.entity.UserHome</home>
                <remote>com.hotjobs.entity.User</remote>
        </ejb-ref>
</application-client>

note: i used the full classnames for my home and remote interfaces

2. put the application-client.xml in the META-INF directory for my ejb.jar
3. redeploy my .ear

4. write the client
5. write my own getInitialContext() for this client

        public static Context getInitialContext() throws NamingException
                {
                Properties p = new Properties();
                p.put("java.naming.factory.initial","com.evermind.server.ApplicationClientInitialContextFactory");
                p.put("java.naming.provider.url","ormi://localhost/PLJB");
                p.put("java.naming.security.principal","admin");
                p.put("java.naming.security.credentials","whatever");

                return new javax.naming.InitialContext(p);
                }
6. use the getInitialContext and then call lookup() using the _bean class name_(!?!?!)
Then narrowing works.

Context jndiContext = getInitialContext();
Object ref = jndiContext.lookup("UserBean");
UserHome home = (UserHome) PortableRemoteObject.narrow(ref,UserHome.class);

My questions are:

Why do I have to lookup() using the Bean class name?
Why can't i lookup on either "PLJB_User" or "UserHome"?
Am I hopelessly overcomplicating this?



-----Original Message-----
From: Karl Avedal [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 12, 2001 10:15 PM
To: Orion-Interest
Subject: Re: Inconsistent EJB JNDI Locations


Hello Manne,

That's right, that is the way we recommend it to be done. Just want to clarify
something though. It is possible to lookup EJBs in another application. To do
so, use the parent attribute when defining the application in server.xml and the
children application's local context will extend the one of the parent, making
it possible to use EJBs from another application.

Regards,
Karl Avedal

Manne Fagerlind wrote:

> I used the JNDI name "java:comp/env/ejb/MyBean" yesterday and it worked fine
> (older version of Orion; hope they haven't changed it). It seems that the
> object performing the lookup must be located inside the same enterprise
> application (i.e. <application>-entry in server.xml) for this to work,
> though.
>
> /Manne
>
> -----Original Message-----
> From: Gary Shea [mailto:[EMAIL PROTECTED]]
> Sent: 09 March 2001 20:57
> To: [EMAIL PROTECTED]
> Subject: Re: Inconsistent EJB JNDI Locations
>
> On Thu, 8 Mar 2001, Peter Pontbriand wrote:
> > Yes, this is what works for us. Assuming that the Entity EJB is deployed
> > with <ejb-name>MyBean</ejb-name> and that the Session EJB's deployment
> > descriptor has an <ejb-ref-name>ejb/MyBean</ejb-ref-name>, the home
> > interface for MyBean is supposed to be found with
> > 'lookup("java:comp/env/ejb/MyBean")'. Unfortunately, this doesn't work,
> but
> > rather MyBean is found with 'lookup("MyBean")'.
>
> Recently I was looking at the spec while trying to figure out why
> Orion's JNDI setup isn't like the examples in the EJB books.  Turns
> out that the java:comp/env/{jms,ejb,...} locations are 'recommended',
> not mandatory.  Given that the non-Context contents of the env/
> directory must be String objects, it doesn't surprise me that the
> Orion folks decided it was tacky to put objects underneath a
> directory that's supposed to hold strings.  Also, I noticed when
> attempting to create objects below the env/ directory using the
> JNDI api, they somehow get turned into strings!  I'm a little unclear
> on whether this really happened or if I was doing something stupid,
> but it's what I think I saw!
>
> Cheers,
>
>         Gary

Reply via email to