0

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
}
Sevan
  • 669
  • 1
  • 5
  • 18
hoefling
  • 59,418
  • 12
  • 147
  • 194

1 Answers1

0

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);
}
hoefling
  • 59,418
  • 12
  • 147
  • 194