I can read system properties via the CLI interface by
/system-property=propertyname:read-attribute(name="value")
Is there a simple way I can update the property via the CLI interface?
Launch the Management CLI. You can launch the management CLI by running the jboss-cli script provided with JBoss EAP. For Windows Server, use the EAP_HOME\bin\jboss-cli. bat script to launch the management CLI.
Certain aspects of the management CLI can be customized in its configuration file, jboss-cli. xml . This file must be located either in the EAP_HOME/bin directory or in a custom directory specified with the jboss.
You can use the write-attribute
operation to change system property values.
/system-property=propertyname:write-attribute(name="value", value="newValue")
See the answer below for a better description.
You can use the write-attribute
operation.
A healthy workflow for the Management CLI is to expose, read and write resource attributes. To give an example of this workflow, we are going to doing the following steps on a fresh default installation of JBoss Application Server 7.1.0Beta1.
We don't always know the exact name of what we are looking for. We can use a mix of tab completion and wildcard searches to make it easy to expose the resources and attributes. The read-resource
operation is a great start to any workflow, as it exposes all present entities.
[domain@localhost:9999 /] /system-property=*:read-resource
{
"outcome" => "success",
"result" => [{
"address" => [("system-property" => "java.net.preferIPv4Stack")],
"outcome" => "success",
"result" => {
"boot-time" => true,
"value" => "true"
}
}]
}
The read-resource
operation has exposed the java.net.preferIPv4Stack
property. We can query this further by using the read-resource-description
operation.
[domain@localhost:9999 /] /system-property=java.net.preferIPv4Stack:read-resource-description
{
"outcome" => "success",
"result" => {
"description" => "A system property to set on all servers in the domain.",
"head-comment-allowed" => true,
"tail-comment-allowed" => false,
"attributes" => {
"value" => {
"type" => STRING,
"description" => "The value of the system property.",
"required" => false,
"access-type" => "read-write",
"storage" => "configuration",
"restart-required" => "no-services"
},
"boot-time" => {
"type" => BOOLEAN,
"description" => "If true the system property is passed on the command-line to the started server jvm. If false, it will be pushed to the server as part of the startup sequence.",
"required" => false,
"default" => true,
"access-type" => "read-write",
"storage" => "configuration",
"restart-required" => "no-services"
}
}
}
}
The read-resource-description
operation prints information about the resource, including its attributes. We can specifically query these attributes with the read-attribute
operation. Again, tab completion makes it easy to compose these operation strings as you begin typing, and hit tab to complete the string or to suggest available additions.
[domain@localhost:9999 /] /system-property=java.net.preferIPv4Stack:read-attribute(name=boot-time)
{
"outcome" => "success",
"result" => true
}
In the same way that we just queried the attribute, we can change it. In this case, we can use the write-attribute
operation, keeping in mind the intended value type as reported by the read-resource-description
operation. This operation declared the attributed to be BOOLEAN, but you should be able to work this out simply by looking at the existing value in the read-attribute
command (where it is defined).
[domain@localhost:9999 /] /system-property=java.net.preferIPv4Stack:write-attribute(name=boot-time, value=false)
{
"outcome" => "success",
"result" => {
"domain-results" => {"step-1" => undefined},
"server-operations" => undefined
}
}
We can run the read-attribute
operation again to show the value change.
[domain@localhost:9999 /] /system-property=java.net.preferIPv4Stack:read-attribute(name=boot-time)
{
"outcome" => "success",
"result" => false
}
Just to gracefully end the example, let's change the value back to the original state.
[domain@localhost:9999 /] /system-property=java.net.preferIPv4Stack:write-attribute(name=boot-time, value=true)
{
"outcome" => "success",
"result" => {
"domain-results" => {"step-1" => undefined},
"server-operations" => undefined
}
}
Yes, you can write attribute values. To make the process easier, a workflow habit of exposing the attribute values and file type definitions is a good practice, and should make the process clearer.
And for completeness, here's how to remove (undefine) a property attribute:
/system-property=propertyname:undefine-attribute(name=attribute-name)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With