Creating, editing, and deleting WebSphere® variables

You can use WebSphere variables to provide settings for any of the string data type attributes that are contained in the product configuration files.

About this task

WebSphere variables are usually used to specify file paths. The "Variable settings" topic supplies further details about specifying variables and highlights further details about product components that use them.

WebSphere variables are also used to configure:
  • Product path names, such as JAVA_HOME, and APP_INSTALL_ROOT.
  • Configure certain cell-wide or cluster-wide customization values.

The variable scoping mechanism for WebSphere variables enables you to define a variable at the node, cluster, or cell level, as well as at the server level. This mechanism enables you to specify a setting for all of the servers in a node, cluster, or cell, instead of individually specifying the setting for each server.

Avoid trouble: Do not define WebSphere variables in terms of themselves, directly or indirectly. Variable substitution takes place recursively, not sequentially as is the case in a shell script. Therefore a variable defined in terms of itself causes a recursion failure.gotcha

To define a new variable, change the value of an existing variable, or delete an existing variable complete the following steps, as appropriate.

Procedure

  1. Click Environment > WebSphere variables in the administrative console
  2. Select the scope of the variable from the list of available scopes.

    If you create a new variable, it will be created at the selected scope. If you define the same variable at multiple levels, the more granular definition overrides the higher level setting. For example, if you specify the same variable on a cell level and at a node level, the node level setting overrides the cell level setting.

    Scoping variables is particularly important if you are testing data source objects. Variable scoping can cause a data source to fail the test connection, but to succeed at run time, or to pass the test connection, but fail at run time.

  3. Create a new variable.
    1. Click New .
    2. Specify a name, a value, and, optionally, a description for the variable.

      You can create WebSphere variables that support substitution. For example, if you enter ${<variable name>} in the Name field, the value of <variable name> becomes the name of your new WebSphere variable. For example if you enter ${JAVA_HOME} as the name of your variable, the name of the WebSphere variable that is created is the Java™ home directory.

    3. Click OK.
    4. Click Environment > WebSphere variables in the administrative console navigation, and verify that the variable is displayed in the list of variables for the selected scope.

      The administrative console does not pick up typing errors. The variable is ignored if it is referred to incorrectly.

  4. Modify the setting for an existing variable.
    1. Click on the name of the variable that you want to change.
    2. Modify the content of the Values field.

      The Values field for some of the variables that are already defined when you install the product are read-only because changing the values that are specified for those variables might cause product processing errors.

    3. Click OK.
  5. Delete an existing variable.
    1. Select the variable that you want to delete.
    2. Click Delete .
    3. Click OK.
    4. Verify that this variable was removed from the list of variables for the selected scope.
  6. Save your configuration.
  7. Stop the affected servers and start those servers again to put the variable configuration change into effect.

    If the change you made affects a node, you must stop and restart all of the servers on that node. Similarly if the change you made affects a cell, you must stop and restart all of the servers in that cell.

What to do next

If you need to reference a WebSphere variable from within an application, include the following method in the application to expand the string that uses the WebSphere variable. Applications cannot directly access WebSphere variables. Therefore, if you define a WebSphere variable inside of an application, an error message, such as "Unknown variable," is returned.

private String expandVariable(String s) throws
javax.management.JMException {  
com.ibm.websphere.management.AdminService as = 
com.ibm.websphere.management.AdminServiceFactory.getAdminService 
();  

String server = as.getProcessName();  

java.util.Set result = as.queryNames(new javax.management.ObjectName("*:*,type=AdminOperations,process=" 
+ server), null);  

return (String)as.invoke((javax.management.ObjectName) 
result.iterator().next(),"expandVariable",new Object[] 
{"${"+s+"}"}, new String[] {"java.lang.String"});
Similarly, you can include the following lines of code in a script file if you want to use a script command to expand WebSphere variables.
  • Using Jacl:
    set mbean [$AdminControl completeObjectName WebSphere:*,type=AdminOperations]
    $AdminControl invoke $mbean expandVariable {{"${APP_INSTALL_ROOT}"}}
  • Using Jython:
    AdminOperations = AdminControl.completeObjectName('WebSphere:*,type=AdminOperations')
    print AdminControl.invoke(AdminOperations, 'expandVariable', '${APP_INSTALL_ROOT}')



In this information ...


IBM Redbooks, demos, education, and more

(Index)

Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

Task topic    

Terms of Use | Feedback

Last updated: Oct 21, 2010 5:30:17 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=compass&product=was-nd-iseries&topic=trun_variable
File name: tcws_variable.html