Using WebSphere variable in JavaEE application

2011/10/20

There is a section in the WebSphere Admin console called WebSphere variables (located under Environment), where you can … manage WebSphere variables (WAS variables). But how can one use these WAS variables within a JavaEE application? There is a proprietary way to load them which I will not mention here.

A better way in my opinion is to bridge the WAS variable to an environment variable. Then it can simply be accessed through System.getProperty(“varName”); It’s also easy to access the variable on Tomcat without touching the code.

To bridge a WAS variable:

  1. Log on to your WAS console.
  2. Add a WAS variable “myapp.myVar” under Environment -> WebSphere variables
  3. Go to (something like) Servers -> Server Types -> Websphere application servers -> YOUR_SERVER -> Java and process management -> Process definition -> Java virtual machine -> Custmo properties
  4. Define a new variable myapp.myVar = ${myapp.myVar}
  5. Save and restart.

The value of myapp.myVar can now be obtained: System.getProperty(“myapp.myVar”)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: