Add/remove/update system properties in JBoss EAP 8 / 7 / 6
Environment
- Red Hat JBoss Enterprise Application Platform (JBoss EAP)
- 8
- 7
- 6
Issue
-
How can I add/remove/remove all system properties with the CLI?
-
Is there a replacement for
properties-service.xml? -
Is there an alternative to using
JAVA_OPTSfor system properties? -
Tried manually removing the system property and got error
{"JBAS014653: Composite operation failed and was rolled back. Steps that failed: " => {"Operation step-1" => "JBAS014803: Duplicate resource [(\"system-property\ " => \"foo\")]"}} -
Can we change system properties on without a restart?
-
How to update a system property using the jboss-cli in JBoss EAP 8 ?
Resolution
System properties are specified like such in standalone(-*).xml or domain.xml/host.xml:
<system-properties>
<property name="foo" value="bar" boot-time="true"/> <!-- boot-time disallowed in standalone*.xml, see below -->
</system-properties>
Note:
- The
boot-timeattribute can be available only in the domain mode. It can be used to have the host controller spawn new EAP instances with system properties on the JVM invocation when theboot-timeattribute set totrue. - If you need to set system properties that are available in the start-up in the *standalone *mode like the
boot-timeattribute, you can set system properties via the java command line. (Note that this way doesn't work for the domain mode. )-
standalone.conf: Add to environment variableJAVA_OPTSinstandalone.conf:JAVA_OPTS="$JAVA_OPTS -Dfoo=bar" -
standalone.sh: Set straight on the command line at startup in standalone mode, for example:./standalone.sh -Dfoo=bar
-
It's possible to add/remove system properties by CLI command. See the following for details.
Standalone CLI
-
ADD
To add system properties:/system-property=foo:add(value="bar")then the following entry goes into the
standalone(-*).xml:<system-properties> <property name="foo" value="bar"/> </system-properties> -
REMOVE
To remove the above system properties:/system-property=foo:remove -
LIST
To get a list of defined system properties:ls /system-propertyIt's possible to remove all defined system properties by removing each system-property which is listed in the above results using
:removeinstead of:add.
Domain CLI
-
server-group level
-
ADD
To add system properties:/server-group=main-server-group/system-property=foo:add(value=bar)then the following entry goes into
<server-group>indomain.xml:<server-group name="main-server-group" profile="full"> ...(snip)... <system-properties> <property name="foo" value="bar"/> </system-properties> ...(snip)... </server-group> -
UPDATE
To update the above system property:/server-group=main-server-group/system-property=foo:write-attribute(name=value,value=bar1) -
UPDATE
To remove the above system properties:/server-group=main-server-group/system-property=foo:remove -
LIST
To get a list of system properties defined in the<server-group>:ls /server-group=main-server-group/system-propertyIt's possible remove all defined system properties by removing each system-property which is listed in the above results using
:removeinstead of:add.
-
-
server level
-
ADD
It's possible to add system properties at server level by the following CLI:/host=master/server-config=server-one/system-property=foo:add(value=bar)then the following entry goes into
<server>inhost.xml:<servers> ...(snip)... <server name="server-one" group="main-server-group" auto-start="true"> <system-properties> <property name="foo" value="bar"/> </system-properties> ...(snip)... </server> ...(snip)... </servers> -
REMOVE
To remove the above system properties:/host=master/server-config=server-one/system-property=foo:remove -
LIST
To get a list of system properties defined in the<server>:ls /host=master/server-config=server-one/system-propertyIt's possible remove all defined system properties by removing each system-property which is listed in the above results using
:removeinstead of:add.
-
NOTE :If multiple property values to a single property is required then use double quotes " " as below :
/server-group=group-name/system-property=https.protocols:add(value="TLSv1,TLSv1.1,TLSv1.2")
Root Cause
If configuration files are manually edited, make sure to restart the server, host controller and process controller for changes to take effect.
Passing parameters vs passing file with parameters
One can pass a file parameter with standalone.sh -P <file> (or domain.sh -P
where file is:
myproperty=foo
otherproperty=bar
afinalproperty=baz
Diagnostic Steps
-
For this error, try to remove the system property via cli command specified above first.
Operation step-1" => "JBAS014803: Duplicate resource -
Try restarting the server if it doesn't work.
-
Check the runtime value of the property with
jinfo. OnRed Hat Enterprise Linuxrun:$ jinfo -sysprops ${JAVA_PID} | grep fooWhere
${JAVA_PID}is the id of the JBoss EAP Server process, and "foo" is the system property name.
The output should look like:foo = barNote Make sure the
jinfois the same version of the JDK as the JBoss EAP Server or it will print an error like:sun.jvm.hotspot.runtime.VMVersionMismatchException: Supported versions are 25.212-b04. Target VM is 25.91-b14
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.