You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mike Reidy <mi...@gmail.com> on 2009/03/25 18:54:48 UTC

Setting Tomcat System Properies **without** -D on Command Line

Hello,

I would like to be able to configure system properties at Tomcat start-up
*without* adding them to the startup command line, for example you might add
-Dxx.yyy.zzz=123 to the command line to add a system property called
xxx.yyy.zzz with a value of 123.  I want something other than this....

I was hoping that there might be a way of loading an additional properties
file in a similar way to catalina.properties but I cannot see this in
documentation.  Does this exist?  If so can someone point me at the
documentation please.

If this is not the case is there a standard way that would be the
recommended way of writing a custom plugin for Tomcat to do this?


Thank you for your time & effort,

M

Re: Setting Tomcat System Properies **without** -D on Command Line

Posted by Tim Funk <fu...@joedog.org>.
The custom way would be to write a startup listener that its only goal 
is to load a prop file and promote its properties into the System 
environment.

It could look somethng like this:
package cowbell;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;

public class PropListener implements LifecycleListener {
     public void lifecycleEvent(LifecycleEvent event) {
         if (Lifecycle.INIT_EVENT.equals(event.getType())) {
             try {
                 System.getProperties().load("fixMe");
                } catch(Throwable evil){
             }
         }
     }
}


And in server.xml like this:

   <Listener className="cowbell.PropListener " />


-Tim


Mike Reidy wrote:
> Hello,
> 
> I would like to be able to configure system properties at Tomcat start-up
> *without* adding them to the startup command line, for example you might add
> -Dxx.yyy.zzz=123 to the command line to add a system property called
> xxx.yyy.zzz with a value of 123.  I want something other than this....
> 
> I was hoping that there might be a way of loading an additional properties
> file in a similar way to catalina.properties but I cannot see this in
> documentation.  Does this exist?  If so can someone point me at the
> documentation please.
> 
> If this is not the case is there a standard way that would be the
> recommended way of writing a custom plugin for Tomcat to do this?


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


RE: Setting Tomcat System Properies **without** -D on Command Line

Posted by Martin Gainty <mg...@hotmail.com>.
take a look at 
<init-param> implementation in web.xml

http://edocs.bea.com/wls/docs61/webapp/web_xml.html#1039383

HTH
Martin 
______________________________________________ 
Disclaimer and confidentiality note 
This message is confidential and may be privileged. If you are not the intended recipient, we kindly ask you to  please inform the sender. Any unauthorised dissemination or copying hereof is prohibited. This message serves for information purposes only and shall not have any legally binding effect. Given that e-mails can easily be subject to manipulation, we can not accept any liability for the content provided.






> Date: Wed, 25 Mar 2009 17:54:48 +0000
> Subject: Setting Tomcat System Properies **without** -D on Command Line
> From: mike.reidy@gmail.com
> To: users@tomcat.apache.org
> 
> Hello,
> 
> I would like to be able to configure system properties at Tomcat start-up
> *without* adding them to the startup command line, for example you might add
> -Dxx.yyy.zzz=123 to the command line to add a system property called
> xxx.yyy.zzz with a value of 123.  I want something other than this....
> 
> I was hoping that there might be a way of loading an additional properties
> file in a similar way to catalina.properties but I cannot see this in
> documentation.  Does this exist?  If so can someone point me at the
> documentation please.
> 
> If this is not the case is there a standard way that would be the
> recommended way of writing a custom plugin for Tomcat to do this?
> 
> 
> Thank you for your time & effort,
> 
> M

_________________________________________________________________
HotmailĀ® is up to 70% faster. Now good news travels really fast.
http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_70faster_032009

Re: Setting Tomcat System Properies **without** -D on Command Line

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
this is doable, just enter all your properties in catalina.properties

first thing tomcat does is ... System.setProperties( - read 
catalina.properties - ) ;

so you don't need them on the command line

Mike Reidy wrote:
> Hello,
>
> I would like to be able to configure system properties at Tomcat start-up
> *without* adding them to the startup command line, for example you might add
> -Dxx.yyy.zzz=123 to the command line to add a system property called
> xxx.yyy.zzz with a value of 123.  I want something other than this....
>
> I was hoping that there might be a way of loading an additional properties
> file in a similar way to catalina.properties but I cannot see this in
> documentation.  Does this exist?  If so can someone point me at the
> documentation please.
>
> If this is not the case is there a standard way that would be the
> recommended way of writing a custom plugin for Tomcat to do this?
>
>
> Thank you for your time & effort,
>
> M
>
>   


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


RE: Setting Tomcat System Properies **without** -D on Command Line

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Mike Reidy [mailto:mike.reidy@gmail.com] 
> Subject: Setting Tomcat System Properies **without** -D on 
> Command Line
> 
> If this is not the case is there a standard way that would be the
> recommended way of writing a custom plugin for Tomcat to do this?

Tomcat supports use of an admin-supplied setenv.bat or setenv.sh script in which you can specify values for the CATALINA_OPTS environment variable.  This will be used on the command line that starts Tomcat.  You can write the setenv script to read the values you need from anywhere.

 - 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: Setting Tomcat System Properies **without** -D on Command Line

Posted by Rainer Jung <ra...@kippdata.de>.
On 25.03.2009 18:54, Mike Reidy wrote:
> Hello,
>
> I would like to be able to configure system properties at Tomcat start-up
> *without* adding them to the startup command line, for example you might add
> -Dxx.yyy.zzz=123 to the command line to add a system property called
> xxx.yyy.zzz with a value of 123.  I want something other than this....
>
> I was hoping that there might be a way of loading an additional properties
> file in a similar way to catalina.properties but I cannot see this in
> documentation.  Does this exist?  If so can someone point me at the
> documentation please.

You can do it in exactly the same way as catalina.properties, namely all 
lines in catalina.properties are automatically added to the system 
properties. Simply add your additional properties to that file.

Regards,

Rainer

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