IBM Support

Cannot clear existing classpath value in a JVM Properties using wsadmin scripting

Question & Answer


Question

What are the commands to clear/change the existing classpath value in a JVM Properties using wsadmin scripting tool in WebSphere Application Server?
 
I tried to clear existing classpath value with the following command, however, it cannot be cleared.

wsadmin>AdminTask.setJVMProperties('[-nodeName Node01 -serverName server1 -classpath ""]')
Also, I tried to replace the existing classpath to "classpath1" with the following command, however, "classpath1" was added after the existing classpath. The existing classpath remains.

wsadmin>AdminTask.setJVMProperties('[-nodeName Node01 -serverName server1 -classpath "classpath1"]')
(classpath1 = actual path to the class file)

Answer

AdminTask.setJVMProperties command can set/add the value. It cannot clear/replace the value by itself. The above commands work as design.
To change the existing classpath value, you need to clear it before setting new value.
Here is the step on how to clear/change the existing classpath value in a JVM Properties:

Steps:
  • Please start the wsadmin script using jython:
    •      [UNIX/Linux] 
      ./wsadmin.sh -lang jython
           [Windows]      
      wsadmin.bat -lang jython
    • You can use the -conntype NONE option to run in local mode if the dmgr(Deployment Manager) or application servee is not running. The result is that the scripting client is not connected to a running server. You can manage server configuration without the server running.
      e.g.
      ./wsadmin.sh -lang jython -conntype NONE
      wsadmin.bat -lang jython -conntype NONE
  • These sample commands are for the Application Server as node=Node01, server=server1.  You can replace them with your JVM that you need to modify.
    • You can get the list of nodename and servername using the following command after login via wsadmin.
             wsadmin>print AdminConfig.list('Server')
      For example, here is the sample output of application server "server1":
             server1(cells/Cell01/nodes/Node01/servers/server1|server.xml#Server_1)
      You can see cell=Cell01, node=Node01, server=server1
----------------------------------
1) Confirm the current value

wsadmin>print AdminTask.showJVMProperties('[-nodeName Node01 -serverName server1 -propertyName classpath]')

2) Get the configID for JVM you want to modify
wsadmin>server = AdminConfig.getid("/Node:Node01/Server:server1/")

3) Set the target object for JVM you want to modify
wsadmin>jvm = AdminConfig.list('JavaVirtualMachine', server)

4) Run the following command to unset classpath attribute
wsadmin>AdminConfig.unsetAttributes(jvm, '["classpath"]')
==> you can clear the existing classpath value.

5) Run the following command if you want to set new value
wsadmin>AdminTask.setJVMProperties('[-nodeName Node01 -serverName server1 -classpath "classpath1"]')
(classpath1 = actual path to the class file)

6) Save the changes
wsadmin>AdminConfig.save()

7) Verify the change you made
wsadmin>print AdminTask.showJVMProperties('[-nodeName Node01 -serverName server1 -propertyName classpath]')

8) Restart the JVM for the changes to take effect.
----------------------------------

References:
For more detail on wsadmin scripting tool, you can refer to the following links:

[{"Type":"MASTER","Line of Business":{"code":"LOB45","label":"Automation"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"ARM Category":[{"code":"a8m50000000CdTFAA0","label":"WebSphere Application Server traditional-All Platforms-\u003ESystem Management-\u003ETraditional WAS-\u003EAdmin Scripting Tools-\u003Ewsadmin"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]

Document Information

Modified date:
27 February 2022

UID

ibm16557386