WAS v8.5 > Script the application serving environment (wsadmin) > Configure servers with scripting

Configure the Java virtual machine using scripting

As part of configuring an application server, you might define settings that enhance the way your operating system uses of the Java virtual machine.

There are three ways to perform this task. Use the steps in this topic to use the setJVMDebugMode command for the AdminTask object or the AdminConfig object to modify your JVM configuration. Alternatively, we can use the configureJavaVirtualMachine Jython script in the AdminServerManagement script library to enable, disable, or configure the debug mode for the JVM. The wsadmin tool automatically loads the script when the tool starts. Use the following syntax to configure JVM settings using the configureJavaVirtualMachine script:

For additional information and argument definitions, see the documentation for the AdminServerMananagment script library.

The JVM is an interpretive computing engine responsible for running the byte codes in a compiled Java program. The JVM translates the Java byte codes into the native instructions of the host machine. The application server, being a Java process, requires a JVM in order to run, and to support the Java applications running on it. JVM settings are part of an application server configuration.

  1. Start the wsadmin scripting tool.
  2. There are two ways to complete this step. We can use the setJVMDebugMode command for AdminTask or the AdminConfig object to modify your JVM configuration. Choose one of the following configuration methods:

    • Using AdminTask:

      • Jacl:

          $AdminTask setJVMDebugMode {-serverName server1 -nodeName node1 -debugMode true}
      • Using Jython:

          AdminTask.setJVMDebugMode (['-serverName', 'server1', '-nodeName', 'node1', '-debugMode', 'true'])

    • Using the AdminConfig object:

      1. Identify the server and assign it to the server1 variable, as the following example demonstrates:

        • Jacl:

            set server1 [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]
        • Using Jython:
          server1 = AdminConfig.getid('/Cell:mycell/Node:mynode/Server:server1/')
          print server1

        Example output:

          server1(cells/mycell/nodes/mynode/servers/server1|server.xml#Server_1)

      2. Identify the JVM that belongs to the server of interest and assign it to the jvm variable, as the following example demonstrates:

        • Jacl:

            set jvm [$AdminConfig list JavaVirtualMachine $server1]
        • Using Jython:
          jvm = AdminConfig.list('JavaVirtualMachine', server1)
          print jvm

        Example output:

          (cells/mycell/nodes/mynode/servers/server1:server.xml#JavaVirtualMachine_1)

      3. Modify the JVM to enable debugging, as the following example demonstrates:

        • Jacl:
          $AdminConfig modify $jvm {{debugMode true} {debugArgs "-Djava.compiler=NONE -Xdebug -Xnoagent 
          -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7777"}}
        • Using Jython:
          AdminConfig.modify(jvm, [['debugMode', 'true'], ['debugArgs',  "-Djava.compiler=NONE -Xdebug 
          -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7777"]])

  3. Save the configuration changes.

    Use the following command example to save your configuration changes:

      AdminConfig.save()


Related


Configure the JVM
Automating server administration using wsadmin.sh


Reference:

Server settings configuration scripts
Commands for the AdminConfig object using wsadmin.sh