"success"} [standalone@localhost:10990 /] /" /> "success"} [standalone@localhost:10990 /] /" /> "success"} [standalone@localhost:10990 /] /"/>

Are there different kinds of system variables in jboss?

56 Views Asked by At

In jboss-cli I can do

[standalone@localhost:10990 /] /system-property=foo.bar:add(value=baz)
{"outcome" => "success"}

[standalone@localhost:10990 /] /system-property=foo.bar:read-resource
{
    "outcome" => "success",
    "result" => {"value" => "baz"}
}

I can list all the system variables with

[standalone@localhost:10990 /] /core-service=platform-mbean/type=runtime:read-attribute(name=system-properties)

One of them is jboss.home.dir. I do:

[standalone@localhost:10990 /] /system-property=jboss.home.dir:read-resource
{
    "outcome" => "failed",
    "failure-description" => "WFLYCTL0216: Management resource '[(\"system-property\" => \"jboss.home.dir\")]' not foun
d",
    "rolled-back" => true
}

So this is another kind of system variable?

I read that I can do:

[standalone@localhost:10990 /] :resolve-expression(expression=${jboss.home.dir})
{
    "outcome" => "success",
    "result" => "D:\\dev\\eap_wildfly\\eap-7.4.0"
}

But that does not answer my question.

1

There are 1 best solutions below

0
James R. Perkins On

The system-property resource is a way to set system properties or override them. In some cases, depending on when the system property is accessed, that resource might not work.

The jboss.home.dir property is a system property that is always set from the server. You cannot override this in the system-property resource either. If you do:

/system-property=jboss.home.dir:add(value=${jboss.home.dir})

The command would fail with:

{
    "outcome" => "failed",
    "failure-description" => "WFLYSRV0115: System property jboss.home.dir cannot be set via the xml configuration file or from a management client; it's value must be known at initial process start so it can only set from the command line",
    "rolled-back" => true
}

You could however set the jboss.home.dir system property in the JAVA_OPTS environment variable or via the command line like:

$JBOSS_HOME/bin/standalone.sh -Djboss.home.dir=$JBOSS_HOME/

It's not that there are multiple types of system properties, there are just multiple ways to set them. Some properties, like jboss.home.dir or system properties required by the JVM, cannot be set in the system-property configuration resource. However, the system-property configuration simply sets the system property, e.g. System.setProperty(name, value).