I'm trying to deploy a web application on Wilfly 9 using the native management api . How does a correct request look like in that case? When using CLI, the command would be
$JBOSS_CLI --connect --command="deploy /path/to/war"
but it's not meeting the definition of the operation request syntax . I tried to deploy with a request
{
"address" => [("deployment" => "/path/to/war")],
"operation" => "deploy"
}
but get an error response back:
{
"outcome" => "failed",
"failure-description" => "WFLYCTL0216: Management resource '[(\"deployment\" => \"/path/to/war\")]' not found",
"rolled-back" => true
}
Ok, here's what I came up with:
The following cli command achieves the same result as deploy
with file path as parameter: /deployment=my_deployment:add(enabled=true,content[url=file:///path/to/war])
Translated in Java:
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);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.