我在standalone.xml 中有相当常规的数据源定义
<subsystem xmlns="urn:jboss:domain:datasources:2.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/MYDS" pool-name="MYDS" enabled="true" use-java-context="true">
<connection-url>jdbc:hsqldb:file:MYDB</connection-url>
<security>
<user-name>superman</user-name>
</security>
</datasource>
</datasources>
</subsystem>
尝试从命令行更改一些属性,这工作正常:
/subsystem=datasources/data-source=MYDS:write-attribute(name=connection-url,value=achooo)
结果:
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
但是使用 ModelNode API,它让我抓狂。
ModelNode request = new ModelNode();
request.get(ClientConstants.OP_ADDR).add("subsystem", "datasources");
request.get(ClientConstants.OP_ADDR).add("data-source", "MYDS");
request.get(ClientConstants.OP).set(ClientConstants.WRITE_ATTRIBUTE_OPERATION);
request.get("connection-url").set("achooo");
myCliExecutor.executeCliCommandWithResult(request);
结果:
{
"outcome" => "failed",
"failure-description" => "JBAS014746: name may not be null",
"rolled-back" => true,
"response-headers" => {"process-state" => "reload-required"}
}