I have an JavaEE application which needs some certain system properties configured during the runtime.
During the development phase, we set the properties in the .pom.xml
to make it work:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<systemProperties>
<xxx>true</xxx>
</systemProperties>
</configuration>
</plugin>
However I wonder how about if we deploy the application in the production environment?
I have though of set the property during the initialization of the servlet, but it seems that I can not modify the system property once the jvm is runing(from this post):
The JVM memory parameters for a Hotspot Java implementation can only be set via the command line options when the JVM is launched / started. Setting them in the system properties either before or after the JVM is launched will have no effect.
And I have tried to set the properties in the web.xml
(here):
<env-entry>
<env-entry-name>xx</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>xx</env-entry-value>
</env-entry>
But it seems like it does not take affect.
Then I wonder how to solve it?
BTW, in the production environment we may run more than one application under a shared tomcat, so we prefer to set the properties under the application context only.