jbosswildflyjboss-cli

Cannot resolve system property when using referencing it using jboss-cli


I am attempting to flush a JNDI datasource using the jboss-cli, but the datasource is defined using a ${jndi.prefix} variable, and the CLI can't seem to be able to resolve it.

Here is my datasource in standalone.xml:

<datasource jndi-name="${jndi.prefix}/CORE" pool-name="${jndi.prefix}/CORE_Pool" enabled="true" use-java-context="true" use-ccm="true">
    <connection-url>jdbc:sqlserver://10.222.255.100;DatabaseName=CORE</connection-url>
    <driver>sqlserver</driver>
    <pool>
        <min-pool-size>1</min-pool-size>
        <max-pool-size>10</max-pool-size>
        <prefill>true</prefill>
    </pool>
    <security>
        <user-name>CORE_DBO</user-name>
        <password>password</password>
    </security>
</datasource>

and jndi.prefix is defined in system-properties:

<system-properties>
    <property name="jndi.prefix" value="java:"/>
</system-properties>

I can see it using the CLI, but when trying to resolve it, I am told that it is unrecognized:

[standalone@localhost:9990 /] cd system-property
[standalone@localhost:9990 system-property] cd jndi.prefix
[standalone@localhost:9990 system-property=jndi.prefix] ls
value=java:
[standalone@localhost:9990 system-property=jndi.prefix] /subsystem=datasources/data-source=${jndi.prefix}\/CORE_Pool/:read-resource
Unrecognized system property jndi.prefix

I have tried swapping the ${jndi.prefix} in the datasource with the literal value java: and that worked, but we have tons of environments that would have to be updated, so I am not fond of that solution.

Why can't the CLI resolve this variable when it is clearly defined?


Solution

  • The system properties you can use in the CLI aren't the ones defined in your Wildfly configuration :

    System property values used in management CLI commands must have already been defined in order to be resolved. You must either pass in a properties file (--properties=/path/to/file.properties) or property value pairs (-Dkey=value) when starting your management CLI instance. The properties file uses a standard KEY=VALUE syntax.

    (source for EAP, but it's most probably the same for Wildfly)