Applying system properties inside Glassfish
If you’re building an Enterprise Java Bean, a web application or some kind of component that uses references to different (for instance) web service URL’s, then system variables come in handy. These situations can particularly appear inside DTAP environments.
Inside the Glassfish admin console open the configurations node. Depending on if you’re using a cluster configuration or not, you’ll see a couple of nodes like server-config, xxx-cluster-config, and so on. If you’re building software that is running on the xxx-cluster, you have to open the xxx-cluster-config and go to the “System properties” page.
You can do “Add Property” and fill
- Instance Variable Name : your.webservice.url
- Default Value : http://development.your.webservice/hello?WSDL
Inside the admin console of the test, acceptance and production you can do the same, but then with different URL’s.
Inside Java it is very simple to get the value of the system property.
String webserviceURL = System.getProperty("your.webservice.url") ;
It keeps your code cleaner, and free it from all kinds of system value strings spread all over your application(s). Don’t forget to make an installation documentation for maintenance purposes. Thes kind of system configurations can easily be forgotton. Especially when you’re dealing with many web component systems.

Comments are closed.