T
Thomas Bauer
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
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