0

我正在尝试使用本机管理 api在 Wilfly 9 上部署 Web 应用程序。在这种情况下,正确的请求如何?使用 CLI 时,命令为

$JBOSS_CLI --connect --command="deploy /path/to/war"

但不符合操作请求语法的定义。我尝试通过请求进行部署

{
    "address" => [("deployment" => "/path/to/war")],
    "operation" => "deploy"
}

但得到一个错误响应:

{
    "outcome" => "failed",
    "failure-description" => "WFLYCTL0216: Management resource '[(\"deployment\" => \"/path/to/war\")]' not found",
    "rolled-back" => true
}
4

1 回答 1

0

好的,这就是我想出的:

以下 cli 命令deploy与将文件路径作为参数 的结果相同: 用 Ja​​va/deployment=my_deployment:add(enabled=true,content[url=file:///path/to/war]) 翻译:

String address = ...
int port = ...
String user = ...
String pass = ...
Path file = ...
ModelNode request = new ModelNode();
request.get(ClientConstants.OP).set(ClientConstants.ADD);
request.get(ClientConstants.OP_ADDR).add("deployment", "my_deployment");
request.get("enabled").set(true);
request.get("content").add("url", file.toUri().toString());
try (ModelControllerClient conn = ModelControllerClient.Factory.create(address, port, new PasswordClientCallbackHandler(user, null, pass.toCharArray()))) {
    ModelNode response = conn.execute(request);
    Logger.getLogger(Test.class.getName()).info(response);
}
于 2015-12-18T14:10:52.000 回答