GlassFish set-web-env-entry

env-entry elements can be used to configure a webapp without recompiling. Usually one still needs to update them in web.xml, and redeploy the WAR for the new config to take effect. I just noticed GlassFish v3 now supports in-place, dynamic updating web env-entry via its powerful asadmin command. I guess it can also be done in GlassFish admin GUI.

1, download a sample webapp, hello.war, from GlassFish web site, to $GLASSFISH_HOME/domains/domain1/autodeploy/ directory:
wget https://glassfish.dev.java.net/downloads/quickstart/hello.war
2, verify hello.war has been successfully deployed:
cd $GLASSFISH_HOME/bin
./asadmin list-components
3,
./asadmin set-web-env-entry --name=contact-email --value=info@examplexxx.com --type=java.lang.String hello
./asadmin set-web-env-entry --name=debug --value=true --type=java.lang.Boolean hello
4, verify the 2 new env-entry elements:
./asadmin list-web-env-entry hello
Reported 2 env-entry settings

contact-email (java.lang.String) = info@examplexxx.com ignoreDescriptorItem=false //(description not specified)
debug (java.lang.Boolean) = true ignoreDescriptorItem=false //(description not specified)
You can also verify them by viewing $GLASSFISH_HOME/domains/domain1/domain.xml:
<application context-root="/hello" location="${com.sun.aas.instanceRootURI}/applications/hello/" name="hello" object-type="user">
<property name="defaultAppName" value="hello" />
<module name="hello">
<engine sniffer="security" />
<engine sniffer="web">
<web-module-config>
<env-entry>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>info@examplexxx.com</env-entry-value>
<env-entry-name>contact-email</env-entry-name>
</env-entry>
<env-entry>
<env-entry-type>java.lang.Boolean</env-entry-type>
<env-entry-value>true</env-entry-value>
<env-entry-name>debug</env-entry-name>
</env-entry>
</web-module-config>
</engine>
</module>
</application>

To learn more about set-web-env-entry subcommand, try one of the following:
./asadmin help set-web-env-entry
./asadmin set-web-env-entry --help
To list and unset env-entry, use the following asadmin commands:

list-web-env-entry
unset-web-env-entry
The same feature also exists for web context-param, via the following commands:

list-web-context-param
set-web-context-param
unset-web-context-param

Followers

Pageviews Last 7 Days