You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by "Zakharov, Vasily M" <va...@intel.com> on 2007/10/08 16:59:23 UTC

How to specify JNDI names?

Hi, all,

I have an application (SPECjAppServer2004) containing session EJBs that
need to be accessed from outside. When I run the client, it reports:

javax.naming.NameNotFoundException: /OrderAuditSes does not exist in the
system.  Check that the app was successfully deployed.
        at
org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:237)
        at javax.naming.InitialContext.lookup(InitialContext.java:351)
        at ...

What is the expected format of specifying the JNDI names in G2.0.1? What
may I be doing wrong?

I've tried different variations, but never succeeded. JNDI Viewer in
Console shows the necessary EJBs in the tree, without any prefix.

Thank you!

The client is launched like this:
java -cp ...
-Djava.naming.factory.initial=org.apache.openejb.client.RemoteInitialCon
textFactory -Djava.naming.provider.url=rmi://localhost:4201 Client

The Client code is like this:
new InitialContext().lookup("OrderAuditSes");

The application deployment plan can be found here:
http://cwiki.apache.org/confluence/download/attachments/64828/sjas-app.x
ml

Vasily
--------------------------------------------------------------------
Closed Joint Stock Company Intel A/O
Registered legal address: 125252, Moscow, Russian Federation, 
Chapayevsky Per, 14.

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

Re: How to specify JNDI names?

Posted by David Blevins <da...@visi.com>.
Going to move this doc into 2.1 somewhere.  Not sure where the best  
fit is, so feel free to move it again.

-David

On Oct 10, 2007, at 11:21 AM, Hernan Cunico wrote:

> I just ran a manual export of all the wiki spaces and the doc is now  
> visible from cwiki.apache.org/geronimo
>
> I thought it would fit better under "Apache Geronimo  
> Development" (still visible from the wiki main page) but that's just  
> my opinion. Feel free to move the doc wherever you think it's more  
> visible.
> Agreed it would be great to have some working samples as well.
>
> Cheers!
> Hernan
>
> Jarek Gawor wrote:
>> On 10/10/07, dblevins@visi.com <db...@visi.com> wrote:
>>> http://cwiki.apache.org/GMOxDEV/client-jndi-names.html  is the  
>>> right location.
>>> Originally I put it in the GMOxSBOX space as I didn't know where  
>>> Hernan would
>>> want it.
>> I think that should move into 2.0 documentation. It is very hard to
>> find right now and people keep asking about this all the time. Maybe
>> we should also add some actual examples and show the difference
>> between 2.0.1 and 2.0.2+ in JNDI names since we will have users of
>> both versions.
>> Jarek
>


Re: How to specify JNDI names?

Posted by Hernan Cunico <hc...@gmail.com>.
I just ran a manual export of all the wiki spaces and the doc is now visible from cwiki.apache.org/geronimo

I thought it would fit better under "Apache Geronimo Development" (still visible from the wiki main page) but that's just my opinion. Feel free to move the doc wherever you think it's more visible.
Agreed it would be great to have some working samples as well.

Cheers!
Hernan

Jarek Gawor wrote:
> On 10/10/07, dblevins@visi.com <db...@visi.com> wrote:
>> http://cwiki.apache.org/GMOxDEV/client-jndi-names.html  is the right location.
>> Originally I put it in the GMOxSBOX space as I didn't know where Hernan would
>> want it.
> 
> I think that should move into 2.0 documentation. It is very hard to
> find right now and people keep asking about this all the time. Maybe
> we should also add some actual examples and show the difference
> between 2.0.1 and 2.0.2+ in JNDI names since we will have users of
> both versions.
> 
> Jarek
> 

Re: How to specify JNDI names?

Posted by Jarek Gawor <jg...@gmail.com>.
On 10/10/07, dblevins@visi.com <db...@visi.com> wrote:
>
> http://cwiki.apache.org/GMOxDEV/client-jndi-names.html  is the right location.
> Originally I put it in the GMOxSBOX space as I didn't know where Hernan would
> want it.

I think that should move into 2.0 documentation. It is very hard to
find right now and people keep asking about this all the time. Maybe
we should also add some actual examples and show the difference
between 2.0.1 and 2.0.2+ in JNDI names since we will have users of
both versions.

Jarek

Re: How to specify JNDI names?

Posted by Kevan Miller <ke...@gmail.com>.
On Oct 10, 2007, at 12:46 PM, dblevins@visi.com wrote:

>
>> From: Kevan Miller [mailto:kevan.miller@gmail.com]
>> You can find JNDI naming documentation for 2.0.2 here -- http://
>> cwiki.apache.org/GMOxDev/client-jndi-names.html Supposedly this doc
>> got moved to a better location, but I don't see it... Perhaps Hernan
>> or David B can point us to it...
>
> http://cwiki.apache.org/GMOxDEV/client-jndi-names.html  is the  
> right location.
> Originally I put it in the GMOxSBOX space as I didn't know where  
> Hernan would
> want it.

Hey David,
Don't you have better things to be doing? ;-)

Yes. Problem was that this page wasn't contained by higher-level  
documentation (e.g. http://cwiki.apache.org/geronimo/). Looks like  
Hernan has fixed this. I think we could still use a bit more  
twiddling, IMO... This doc should probably be contained by release  
documentation (e.g. http://cwiki.apache.org/GMOxDOC20/ 
documentation.html). That's where most users would be looking for it...

--kevan 
  

RE: How to specify JNDI names?

Posted by db...@visi.com.
Quoting "Zakharov, Vasily M" <va...@intel.com>:

> Kevan,
>
> Thanks for your help! Your solution worked.

Thanks as well, Kevan!

>
> However, in my case the proper JNDI name for the bean turned out to be
> as follows:
> "orders.jar/OrderAuditSes/org.spec.jappserver.orders.orderauditses.ejb.O
> rderAuditSes"
> and I had to patch the source code of the 3rd party application (good I
> had the sources)
> to make it working.
>

The Geronimo sets the artifact id to include the .jar extension when the ejb jar
is in an ear, when it's not in an ear and is all alone the .jar is shaved off. 
The artifact id is used to construct the jndi name thus you get a slightly
different name depending on how you deployed it (in or out of an ear).

> It makes me hope the naming scheme is somehow simplified in G2.0.2. :)

Definitely.  Assuming your interface is an EJBHome/EJBObject you'd get simply
"OrderAuditSesRemoteHome" as your JNDI name.

We would have made them simpler in 2.0.1 but there was a limitation around
supporting javaee app clients that made it so we had to have a name that was as
complete as possible.  We fixed it so old fashioned standalone clients and
javaee clients use different jndi trees so the format of the standalone client
can go back to being simple.  Additionally, you can now change the standalone
client JNDI name format to just about anything you want.

> From: Kevan Miller [mailto:kevan.miller@gmail.com]
> You can find JNDI naming documentation for 2.0.2 here -- http://
> cwiki.apache.org/GMOxDev/client-jndi-names.html Supposedly this doc
> got moved to a better location, but I don't see it... Perhaps Hernan
> or David B can point us to it...

http://cwiki.apache.org/GMOxDEV/client-jndi-names.html  is the right location. 
Originally I put it in the GMOxSBOX space as I didn't know where Hernan would
want it.


Re: How to specify JNDI names?

Posted by Ted Kirby <te...@gmail.com>.
On 10/11/07, Zakharov, Vasily M <va...@intel.com> wrote:
> Kevan,
>
> Sure, it isn't. :) The application queries the beans by ejb-name,
> probably with some prefix that can be specified separately
> (application-wide).
> I've tried to use -Dopenejb.jndiname.failoncollision=true and
> -Dopenejb.jndiname.format="{ejbName}" at Geronimo startup, but that
> changed nothing - probably those options don't work on G2.0.1 I use.

Yes, in G2.0.1, the openejb.jndiname.format is hard-coded to
{ejbName}{interfaceType.annotationName}.  You can't change it.

Ted Kirby

> Thank you!
>
> Vasily
>
>
> -----Original Message-----
> From: Kevan Miller [mailto:kevan.miller@gmail.com]
> Sent: Wednesday, October 10, 2007 8:36 PM
> To: user@geronimo.apache.org
> Subject: Re: How to specify JNDI names?
>
>
> On Oct 9, 2007, at 1:10 PM, Zakharov, Vasily M wrote:
>
> > Kevan,
> >
> > Thanks for your help! Your solution worked.
> >
> > However, in my case the proper JNDI name for the bean turned out to be
> > as follows:
> > "orders.jar/OrderAuditSes/
> > org.spec.jappserver.orders.orderauditses.ejb.O
> > rderAuditSes"
> > and I had to patch the source code of the 3rd party application
> > (good I
> > had the sources)
> > to make it working.
> >
> > It makes me hope the naming scheme is somehow simplified in G2.0.2. :)
> >
> > Thanks again!
>
> You're welcome. Glad that it's working for you...
>
> The default name for your Bean will be OrderAuditSesRemoteHome. I'm
> guessing that this isn't what your 3rd party app is looking for,
> either. There are several ways to fix, including configuring how
> OpenEJB will default JNDI names for beans. For example, the server
> can be configured to use the ejb-name as the default jndi name (which
> I'm guess is what your app is looking for...).
>
> User feedback on this is more than welcome. What default is most
> useful for you or anyone else?
>
> --kevan
> --------------------------------------------------------------------
> Closed Joint Stock Company Intel A/O
> Registered legal address: 125252, Moscow, Russian Federation,
> Chapayevsky Per, 14.
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>

RE: How to specify JNDI names?

Posted by "Zakharov, Vasily M" <va...@intel.com>.
Kevan,

Sure, it isn't. :) The application queries the beans by ejb-name,
probably with some prefix that can be specified separately
(application-wide).
I've tried to use -Dopenejb.jndiname.failoncollision=true and
-Dopenejb.jndiname.format="{ejbName}" at Geronimo startup, but that
changed nothing - probably those options don't work on G2.0.1 I use.

Thank you!

Vasily


-----Original Message-----
From: Kevan Miller [mailto:kevan.miller@gmail.com] 
Sent: Wednesday, October 10, 2007 8:36 PM
To: user@geronimo.apache.org
Subject: Re: How to specify JNDI names?


On Oct 9, 2007, at 1:10 PM, Zakharov, Vasily M wrote:

> Kevan,
>
> Thanks for your help! Your solution worked.
>
> However, in my case the proper JNDI name for the bean turned out to be
> as follows:
> "orders.jar/OrderAuditSes/ 
> org.spec.jappserver.orders.orderauditses.ejb.O
> rderAuditSes"
> and I had to patch the source code of the 3rd party application  
> (good I
> had the sources)
> to make it working.
>
> It makes me hope the naming scheme is somehow simplified in G2.0.2. :)
>
> Thanks again!

You're welcome. Glad that it's working for you...

The default name for your Bean will be OrderAuditSesRemoteHome. I'm  
guessing that this isn't what your 3rd party app is looking for,  
either. There are several ways to fix, including configuring how  
OpenEJB will default JNDI names for beans. For example, the server  
can be configured to use the ejb-name as the default jndi name (which  
I'm guess is what your app is looking for...).

User feedback on this is more than welcome. What default is most  
useful for you or anyone else?

--kevan
--------------------------------------------------------------------
Closed Joint Stock Company Intel A/O
Registered legal address: 125252, Moscow, Russian Federation, 
Chapayevsky Per, 14.

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

Re: How to specify JNDI names?

Posted by Kevan Miller <ke...@gmail.com>.
On Oct 9, 2007, at 1:10 PM, Zakharov, Vasily M wrote:

> Kevan,
>
> Thanks for your help! Your solution worked.
>
> However, in my case the proper JNDI name for the bean turned out to be
> as follows:
> "orders.jar/OrderAuditSes/ 
> org.spec.jappserver.orders.orderauditses.ejb.O
> rderAuditSes"
> and I had to patch the source code of the 3rd party application  
> (good I
> had the sources)
> to make it working.
>
> It makes me hope the naming scheme is somehow simplified in G2.0.2. :)
>
> Thanks again!

You're welcome. Glad that it's working for you...

The default name for your Bean will be OrderAuditSesRemoteHome. I'm  
guessing that this isn't what your 3rd party app is looking for,  
either. There are several ways to fix, including configuring how  
OpenEJB will default JNDI names for beans. For example, the server  
can be configured to use the ejb-name as the default jndi name (which  
I'm guess is what your app is looking for...).

User feedback on this is more than welcome. What default is most  
useful for you or anyone else?

--kevan


RE: How to specify JNDI names?

Posted by "Zakharov, Vasily M" <va...@intel.com>.
Kevan,

Thanks for your help! Your solution worked.

However, in my case the proper JNDI name for the bean turned out to be
as follows:
"orders.jar/OrderAuditSes/org.spec.jappserver.orders.orderauditses.ejb.O
rderAuditSes"
and I had to patch the source code of the 3rd party application (good I
had the sources)
to make it working. 

It makes me hope the naming scheme is somehow simplified in G2.0.2. :)

Thanks again!

Vasily


-----Original Message-----
From: Kevan Miller [mailto:kevan.miller@gmail.com] 
Sent: Monday, October 08, 2007 8:53 PM
To: user@geronimo.apache.org
Subject: Re: How to specify JNDI names?


On Oct 8, 2007, at 10:59 AM, Zakharov, Vasily M wrote:

> Hi, all,
>
> I have an application (SPECjAppServer2004) containing session EJBs  
> that
> need to be accessed from outside. When I run the client, it reports:
>
> javax.naming.NameNotFoundException: /OrderAuditSes does not exist  
> in the
> system.  Check that the app was successfully deployed.
>         at
> org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:237)
>         at javax.naming.InitialContext.lookup(InitialContext.java:351)
>         at ...
>
> What is the expected format of specifying the JNDI names in G2.0.1?  
> What
> may I be doing wrong?
>
> I've tried different variations, but never succeeded. JNDI Viewer in
> Console shows the necessary EJBs in the tree, without any prefix.
>
> Thank you!
>
> The client is launched like this:
> java -cp ...
> - 
> Djava.naming.factory.initial=org.apache.openejb.client.RemoteInitialCo

> n
> textFactory -Djava.naming.provider.url=rmi://localhost:4201 Client
>
> The Client code is like this:
> new InitialContext().lookup("OrderAuditSes");
>
> The application deployment plan can be found here:
> http://cwiki.apache.org/confluence/download/attachments/64828/sjas- 
> app.x
> ml

Vasily,
The best way that I know how to get the JNDI name is from having it  
logged during deployment. JNDI name for an EJB will be logged if you  
turn on INFO logging in 2.0.1. This is configured by default in the  
soon to be 2.0.2. For 2.0.1 edit your server.log4j.properties file  
and change your log4j.rootLogger and log4j.appender.FILE.Threshold to  
the following:

log4j.rootLogger=INFO, CONSOLE, FILE
log4j.appender.FILE.Threshold=INFO

You should see log entries of the following form:

11:47:42,435 INFO  [startup] Assembling app: /geronimo-jetty6- 
jee5-2.0.1/var/temp/geronimo-deploymentUtil32038.jar
11:47:42,796 INFO  [startup] Jndi(name=GeneralEJB.jar/My/ejbs.My)
11:47:42,796 INFO  [startup] Created Ejb(deployment-id=GeneralEJB.jar/ 
My, ejb-name=My, container=Default Stateless Container)

The JNDI naming scheme is changing in 2.0.2 (the change is a bit  
unfortunate, but the naming scheme is more straightforward...). By  
default: {EjbName}{AnnotationType}

You can find JNDI naming documentation for 2.0.2 here -- http:// 
cwiki.apache.org/GMOxDev/client-jndi-names.html Supposedly this doc  
got moved to a better location, but I don't see it... Perhaps Hernan  
or David B can point us to it...

For 2.0.2 the log will contain entries of the following form:

12:21:04,363 INFO  [startup] Assembling app: /Users/kevan/geronimo/ 
server/branches/2.0.2/target/geronimo-jetty6-jee5-2.0.2-SNAPSHOT/var/ 
temp/geronimo-deploymentUtil64534.jar
12:21:04,762 INFO  [startup] Jndi(name=MyRemoteHome) --> Ejb 
(deployment-id=GeneralEJB.jar/My)
12:21:04,762 INFO  [startup] Created Ejb(deployment-id=GeneralEJB.jar/ 
My, ejb-name=My, container=Default Stateless Container)
12:21:04,763 INFO  [startup] Deployed Application(path=/Users/kevan/ 
geronimo/server/branches/2.0.2/target/geronimo-jetty6-jee5-2.0.2- 
SNAPSHOT/var/temp/geronimo-deploymentUtil64534.jar)

--kevan
--------------------------------------------------------------------
Closed Joint Stock Company Intel A/O
Registered legal address: 125252, Moscow, Russian Federation, 
Chapayevsky Per, 14.

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

Re: How to specify JNDI names?

Posted by Kevan Miller <ke...@gmail.com>.
On Oct 8, 2007, at 10:59 AM, Zakharov, Vasily M wrote:

> Hi, all,
>
> I have an application (SPECjAppServer2004) containing session EJBs  
> that
> need to be accessed from outside. When I run the client, it reports:
>
> javax.naming.NameNotFoundException: /OrderAuditSes does not exist  
> in the
> system.  Check that the app was successfully deployed.
>         at
> org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:237)
>         at javax.naming.InitialContext.lookup(InitialContext.java:351)
>         at ...
>
> What is the expected format of specifying the JNDI names in G2.0.1?  
> What
> may I be doing wrong?
>
> I've tried different variations, but never succeeded. JNDI Viewer in
> Console shows the necessary EJBs in the tree, without any prefix.
>
> Thank you!
>
> The client is launched like this:
> java -cp ...
> - 
> Djava.naming.factory.initial=org.apache.openejb.client.RemoteInitialCo 
> n
> textFactory -Djava.naming.provider.url=rmi://localhost:4201 Client
>
> The Client code is like this:
> new InitialContext().lookup("OrderAuditSes");
>
> The application deployment plan can be found here:
> http://cwiki.apache.org/confluence/download/attachments/64828/sjas- 
> app.x
> ml

Vasily,
The best way that I know how to get the JNDI name is from having it  
logged during deployment. JNDI name for an EJB will be logged if you  
turn on INFO logging in 2.0.1. This is configured by default in the  
soon to be 2.0.2. For 2.0.1 edit your server.log4j.properties file  
and change your log4j.rootLogger and log4j.appender.FILE.Threshold to  
the following:

log4j.rootLogger=INFO, CONSOLE, FILE
log4j.appender.FILE.Threshold=INFO

You should see log entries of the following form:

11:47:42,435 INFO  [startup] Assembling app: /geronimo-jetty6- 
jee5-2.0.1/var/temp/geronimo-deploymentUtil32038.jar
11:47:42,796 INFO  [startup] Jndi(name=GeneralEJB.jar/My/ejbs.My)
11:47:42,796 INFO  [startup] Created Ejb(deployment-id=GeneralEJB.jar/ 
My, ejb-name=My, container=Default Stateless Container)

The JNDI naming scheme is changing in 2.0.2 (the change is a bit  
unfortunate, but the naming scheme is more straightforward...). By  
default: {EjbName}{AnnotationType}

You can find JNDI naming documentation for 2.0.2 here -- http:// 
cwiki.apache.org/GMOxDev/client-jndi-names.html Supposedly this doc  
got moved to a better location, but I don't see it... Perhaps Hernan  
or David B can point us to it...

For 2.0.2 the log will contain entries of the following form:

12:21:04,363 INFO  [startup] Assembling app: /Users/kevan/geronimo/ 
server/branches/2.0.2/target/geronimo-jetty6-jee5-2.0.2-SNAPSHOT/var/ 
temp/geronimo-deploymentUtil64534.jar
12:21:04,762 INFO  [startup] Jndi(name=MyRemoteHome) --> Ejb 
(deployment-id=GeneralEJB.jar/My)
12:21:04,762 INFO  [startup] Created Ejb(deployment-id=GeneralEJB.jar/ 
My, ejb-name=My, container=Default Stateless Container)
12:21:04,763 INFO  [startup] Deployed Application(path=/Users/kevan/ 
geronimo/server/branches/2.0.2/target/geronimo-jetty6-jee5-2.0.2- 
SNAPSHOT/var/temp/geronimo-deploymentUtil64534.jar)

--kevan