Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / August 2004

Tip: Looking for answers? Try searching our database.

Using JNDI Resources in Tomcat

Thread view: 
Thomas Bauer - 20 Aug 2004 09:26 GMT
Hello!

I have several webapps installed on my tomcat that share various
configuration elements (config-params, resource-info etc.)
Currently I have them configured as init-params in their
deployment-descriptors (web.xml).

Waht I want to do is to configure them on a single point and have the
possibility to change it during runtime.
So I thought about doing this:
Setting up some JNDI-Environment entries in my tomcat-server and link to
them from my webapp.

I can see my environment etries in the admin webapp.
I have something like this in my web.xml:

    <resource-env-ref>
        <resource-env-ref-name>someInfo</resource-env-ref-name>
        <resource-env-ref-type>java.lang.String</resource-env-ref-type>
    </resource-env-ref>

and the JNDI entry in my server.xml looks like this:

<Environment description="" name="someInfo" override="false"
type="java.lang.String" value="hello world"/>

My code to lookup the entry is this:

String someInfo = (String) ctx.lookupLink("java:/comp/env/someInfo");

But I keep getting a NamingException.
If I iterate over my ctx.list("java:/comp/env");

I see there is a variable "someInfo" and isRelative() is true.

How can I access those global env. entries? Am I doing something wrong?
Is there a good tutorial on this one? (I've read tomcat jndi stuff and
searched the web for tutorials already)
Can you tell me the "best practice" how to acomplish such task (maybe
having default params and webapp-dependent entries and
webapp-independent entries).

Thank you very much!

Thomas Bauer
Juha Laiho - 20 Aug 2004 18:12 GMT
Thomas Bauer <thomas-spam@bauer.dhs.org> said:
>I have several webapps installed on my tomcat that share various
>configuration elements (config-params, resource-info etc.)
[quoted text clipped - 6 lines]
>Setting up some JNDI-Environment entries in my tomcat-server and link to
>them from my webapp.
...
>How can I access those global env. entries? Am I doing something wrong?
>Is there a good tutorial on this one? (I've read tomcat jndi stuff and
>searched the web for tutorials already)

Have you looked at the JndiServlet among the examples distributed with
Tomcat?
Signature

Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
        PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.