You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Laicreparc <a5...@jnxjn.com> on 2011/04/13 17:38:35 UTC

Re: 'Parametrizing' context.xml?

How can the variable (i.e. here BPVAL be set)? E.g. in server.xml? Is
<context-param> really in context.xml? Looks more like web.xml to me.



Bill Barker wrote:
> 
> 
> "Mario Splivalo" <ma...@megafon.hr> wrote in message 
> news:4B27994E.5080808@megafon.hr...
>> Bill Barker wrote:
>>> "Mario Splivalo" <ma...@megafon.hr> wrote in message
>>> news:4B266622.5060806@megafon.hr...
>>>
>>> Tomcat also supports ant-style variable replacement, so using that then
>>> Ken's example would look like:
>>>   <context-param>
>>>      <param-name>baseprefix</param-name>
>>>      <param-value>${BPVAL}</param-value>
>>>   </context-param>
>>>
>>> where BPVAL is a Java system property (that can be set in
>>> catalina.properties for example).
>>
>> And, those can be used also in apps context.xml?
>>
> 
> Yes, this should work in context.xml (and even server.xml).
> 
>>> Of course, this only works for Tomcat.  Ken's suggestion will work on
>>> any
>>> servlet container.
>>
>> Yes, in the long run I'll stick to those, but since we're only using
>> Tomcat for now it would be much easier not to fiddle with ant.
>>
>> Thank you all!
>>
>> Mike 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/%27Parametrizing%27-context.xml--tp26780552p31389193.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


RE: 'Parametrizing' context.xml?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: pzwedhhs [mailto:pzwedhhs@guerrillamailblock.com] 
> Subject: Re: 'Parametrizing' context.xml?

> I still could not find out, how to access the variable in context.xml.

Are you sure that the context.xml you're modifying is the one being used?  If there's a <Context> element in conf/Catalina/[host]/[appName].xml, that will override the one in your webapp's META-INF/context.xml file.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


Re: 'Parametrizing' context.xml?

Posted by pzwedhhs <pz...@guerrillamailblock.com>.
Ok, adding a line in catalina.properties seems to set the value at least. It
appears, when I call System.getProperties() inside the Java code. However, I
still could not find out, how to access the variable in context.xml.


Laicreparc_ wrote:
> 
> Ok, I have added the line
> 
> DBVAL=mydb_dev
> 
> to catalina.properties.
> 
> Now I define a Realm in my webabb's context.xml:
> 
> <Realm className="org.apache.catalina.realm.JDBCRealm"
> 		driverName="org.postgresql.Driver"
> 		connectionURL="jdbc:postgresql://myserver:5432/${DBVAL}"
> 		connectionName="xxx" connectionPassword="yyy"
> 		userTable="users" userRoleTable="roles"
> 		userNameCol="name" userCredCol="pw" roleNameCol="role"
> 		digest="MD5" />
> 
> However, in the logfiles I can find:
> org.postgresql.util.PSQLException: FATAL: database "${DBVAL}" does not
> exist
> 
> It seems, that the parameter value was not replaced.
> 
> What I would like to have is to define a Realm once in context.xml, that
> will be used both on a development and on a productive server. The servers
> define the actual name of the database (here "mydb_dev"), e.g. in
> catalina.properties.
> 
> 
> Christopher Schultz-2 wrote:
>> 
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>> 
>> Laicreparc,
>> 
>> On 4/13/2011 11:38 AM, Laicreparc wrote:
>>> How can the variable (i.e. here BPVAL be set)? E.g. in server.xml?
>> 
>> Did you read the post? It says how to set those values.
>> 
>>> Is <context-param> really in context.xml? Looks more like web.xml to
>>> me.
>> 
>> I think it was just an example. Would you prefer <Resource
>> param="${BPVAL}" />?
>> 
>> - -chris
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.10 (MingW32)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>> 
>> iEYEARECAAYFAk2mCvYACgkQ9CaO5/Lv0PAM/ACdHAmti7Wf11o5AUqivmk3iZtw
>> VpsAoLv7NToDVbVThrVCRgO1KTlX21nt
>> =g1qE
>> -----END PGP SIGNATURE-----
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/%27Parametrizing%27-context.xml--tp26780552p31407341.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: 'Parametrizing' context.xml?

Posted by Laicreparc_ <a7...@jnxjn.com>.
Ok, I have added the line

DBVAL=mydb_dev

to catalina.properties.

Now I define a Realm in my webabb's context.xml:

<Realm className="org.apache.catalina.realm.JDBCRealm"
		driverName="org.postgresql.Driver"
		connectionURL="jdbc:postgresql://myserver:5432/${DBVAL}"
		connectionName="xxx" connectionPassword="yyy"
		userTable="users" userRoleTable="roles"
		userNameCol="name" userCredCol="pw" roleNameCol="role"
		digest="MD5" />

However, in the logfiles I can find:
org.postgresql.util.PSQLException: FATAL: database "${DBVAL}" does not exist

It seems, that the parameter value was not replaced.

What I would like to have is to define a Realm once in context.xml, that
will be used both on a development and on a productive server. The servers
define the actual name of the database (here "mydb_dev"), e.g. in
catalina.properties.


Christopher Schultz-2 wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Laicreparc,
> 
> On 4/13/2011 11:38 AM, Laicreparc wrote:
>> How can the variable (i.e. here BPVAL be set)? E.g. in server.xml?
> 
> Did you read the post? It says how to set those values.
> 
>> Is <context-param> really in context.xml? Looks more like web.xml to
>> me.
> 
> I think it was just an example. Would you prefer <Resource
> param="${BPVAL}" />?
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk2mCvYACgkQ9CaO5/Lv0PAM/ACdHAmti7Wf11o5AUqivmk3iZtw
> VpsAoLv7NToDVbVThrVCRgO1KTlX21nt
> =g1qE
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/%27Parametrizing%27-context.xml--tp26780552p31397140.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: 'Parametrizing' context.xml?

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

Laicreparc,

On 4/13/2011 11:38 AM, Laicreparc wrote:
> How can the variable (i.e. here BPVAL be set)? E.g. in server.xml?

Did you read the post? It says how to set those values.

> Is <context-param> really in context.xml? Looks more like web.xml to
> me.

I think it was just an example. Would you prefer <Resource
param="${BPVAL}" />?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2mCvYACgkQ9CaO5/Lv0PAM/ACdHAmti7Wf11o5AUqivmk3iZtw
VpsAoLv7NToDVbVThrVCRgO1KTlX21nt
=g1qE
-----END PGP SIGNATURE-----

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