How to add jvm-options at host level in domain mode in JBoss EAP

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x
    • 7.x
    • 8.x

Issue

  • How to add new-size to jvm settings for a specific host? When trying to add it via CLI, it seems on heap-size and perm-size are available. We're using domain mode. Can it just be put in jvm-options?
  • How to add new JBoss JVM template via CLI.

Resolution

Note: The permgen attributes (permgen-size, max-permgen-size) apply only to EAP 6 running on Java 7 or earlier. On EAP 7 and later (which require Java 8+), PermGen has been replaced by Metaspace. Use -XX:MetaspaceSize and -XX:MaxMetaspaceSize as jvm-options instead.

Default configuration

Following is the configuration for "out of the box" on EAP 6 host.xml:

<jvms>
      <jvm name="default">
            <heap size="64m" max-size="256m"/>
            <permgen size="256m" max-size="256m"/>
            <jvm-options>
                <option value="-server"/>
            </jvm-options>
      </jvm>
</jvms>

Adding a jvm-option to a JVM

/host=<HOST>/jvm=default:add-jvm-option(jvm-option="-XX:NewSize=320m")

Defining the above will add the "jvm-option" to the JVM named "default" defined in the host configuration file.

Resulting in the following snippet in host.xml:

<jvms>
      <jvm name="default">
            <heap size="64m" max-size="256m"/>
            <permgen size="256m" max-size="256m"/>
            <jvm-options>
                <option value="-server"/>
                <option value="-XX:NewSize=320m"/>
            </jvm-options>
      </jvm>
</jvms>

Adding new JVM template

/host=<HOST>/jvm=MY_TEMPLATE/:add(max-heap-size=1028m,env-classpath-ignored=false,permgen-size=256m,max-permgen-size=256m,heap-size=1028m,jvm-options=["-server"])

Resulting in the following snippet in host.xml:

<jvms>
      [...]
      <jvm name="MY_TEMPLATE" env-classpath-ignored="false">
            <heap size="1028m" max-size="1028m"/>
            <permgen size="256m" max-size="256m"/>
            <jvm-options>
                <option value="-server"/>
            </jvm-options>
      </jvm>
      [...]
</jvms>

This template can be assigned to server groups and servers.

Adding a jvm-option at the server-group level

/server-group=server-group/jvm=default:write-attribute(name=jvm-options, value=["-XX:NewSize=320m", "-XX:MetaspaceSize=96m"])
    <server-groups>
        <server-group name="server-group" profile="server">
            <jvm name="default">
                <heap size="256m" max-size="256m"/>
                <jvm-options>
                    <option value="-XX:NewSize=320m"/>
                    <option value="-XX:MetaspaceSize=96m"/>
                </jvm-options>
            </jvm>

Adding a jvm-option at the server instance level

/host=<HOST>/server-config=server1/jvm=default:add
/host=<HOST>/server-config=server1/jvm=default:write-attribute(name=jvm-options,value=["-XX:NewSize=320m"])
        <server name="server1" group="server-group" auto-start="true">
            <jvm name="default">
                <jvm-options>
                    <option value="-XX:NewSize=320m"/>
                </jvm-options>
            </jvm>
        </server>
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.