You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Martin Gamper <we...@gmail.com> on 2012/12/03 14:03:22 UTC

Reuse JNDI Properties

Hey everybody!

I am looking for a solution to reuse a JNDI Property which is set in the
context.xml :
in my "${catalina.home}/conf/context.xml" following
    <Environment name="nodeName" type="java.lang.String"
value="superFantasticNode" override="false" />
I use this value for several different purposes.

Now I want to define (for my J2EE application) another value for special
Log- Files. And therefore I use another JNDI property ... and in this
Property I'd like to "reuse" the previously set "nodeName"-variable.

In my Fantasy it would work like this:
    <Environment name="loggingPath"
        value="${catalina.home}/logs/${nodeName}.log"
type="java.lang.String"
        override="false" />

But it does not.

Do you know any solution (despite from changing my code) to achieve this?

Sincerly
Martin

Re: Reuse JNDI Properties

Posted by Konstantin Kolinko <kn...@gmail.com>.
2012/12/3 Christopher Schultz <ch...@christopherschultz.net>:
> On 12/3/12 8:03 AM, Martin Gamper wrote:
>> Hey everybody!
>>
>> I am looking for a solution to reuse a JNDI Property which is set
>> in the context.xml : in my "${catalina.home}/conf/context.xml"
>> following <Environment name="nodeName" type="java.lang.String"
>> value="superFantasticNode" override="false" /> I use this value for
>> several different purposes.
>>
>> Now I want to define (for my J2EE application) another value for
>> special Log- Files. And therefore I use another JNDI property ...
>> and in this Property I'd like to "reuse" the previously set
>> "nodeName"-variable.
>>
>> In my Fantasy it would work like this: <Environment
>> name="loggingPath" value="${catalina.home}/logs/${nodeName}.log"
>> type="java.lang.String" override="false" />
>>
>> But it does not.
>
> Tomcat has a very limited set of cases where ${...} will do
> replacements for system properties. I think it's definitely worth
> filing an enhancement request for this kind of thing: it's a *very*
> useful feature to have.

The ${...} handling can be extended by defining a class that
implements PropertySource interface,
http://tomcat.apache.org/tomcat-7.0-doc/config/systemprops.html

BTW, in your case where you are specifying a global setting,
you can define nodeName property in conf/catalina.properties file.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Reuse JNDI Properties

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Martin,

On 12/3/12 8:03 AM, Martin Gamper wrote:
> Hey everybody!
> 
> I am looking for a solution to reuse a JNDI Property which is set
> in the context.xml : in my "${catalina.home}/conf/context.xml"
> following <Environment name="nodeName" type="java.lang.String" 
> value="superFantasticNode" override="false" /> I use this value for
> several different purposes.
> 
> Now I want to define (for my J2EE application) another value for
> special Log- Files. And therefore I use another JNDI property ...
> and in this Property I'd like to "reuse" the previously set
> "nodeName"-variable.
> 
> In my Fantasy it would work like this: <Environment
> name="loggingPath" value="${catalina.home}/logs/${nodeName}.log" 
> type="java.lang.String" override="false" />
> 
> But it does not.

Tomcat has a very limited set of cases where ${...} will do
replacements for system properties. I think it's definitely worth
filing an enhancement request for this kind of thing: it's a *very*
useful feature to have.

> Do you know any solution (despite from changing my code) to achieve
> this?

I would do a search-and-replace as part of the deployment process. Is
this something that does into META-INF/context.xml (at the webapp
level) or into conf/context.xml (at the server level)?

If at the webapp level, you'd have to re-roll a WAR file for each
server you want to target. That's not necessarily a big deal: you can
script it with ant or even bash if you want (unzip, replace, update-zip).

I guess the same thing could be done at the server level, though it
would only have to be done once each time you install (or upgrade) Tomcat.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iEYEARECAAYFAlC8xMwACgkQ9CaO5/Lv0PD/yACcDehCXdQwQv0DepMXvoKjNrIs
YSEAoKuitDvT3ziCeV3tYh/nkSVMLRzn
=5me9
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org