0
votes

I need to deploy an ear file to wildfly server.

When copying the ear file to deployment folder of wildfly and starting the server, it is getting deployed. But that is not my requirement. I want to deploy it using jboss-cli. When I opened jboss-cli manually and executed the below command it is getting deployed.

jboss-cli.bat --connect --command="deploy --force C:\\Users\\jmk\\git\\ec\\EC\\build\\libs\\test.ear"

Now I have to execute this command using Java code. I tried the below code:

ProcessBuilder pb = new ProcessBuilder("jboss-cli.bat", "--connect", "--command","\"deploy --force C:\\Users\\jmartin5\\git\\ecommerce\\ECommerce\\build\\libs\\ECommerce.ear\"");
 Process p = pb.start();

But the deployment is not happening.

How to write some code to deploy using ProcessBuilder()?

1
I want to write the code to deploy the server in build.gradle (Eclipse IDE). I tried this code: ProcessBuilder pb = new ProcessBuilder("jboss-cli.bat", "--connect", "--command=deploy --force C:\\Users\\jmartin5\\git\\ecommerce\\ECommerce\\build\\libs\\ECommerce.ear"); When I run the task, the build is successful. But I can't see EAR file getting deployed in console. Please help me.Jince Martin

1 Answers

0
votes

Remove the pair of \" in the last argument of the ProcessBuilder constructor. You don't need them because ProcessBuilder will not tokenize the parameters by space.

Also, combine the 3rd and 4th arguments like this:

ProcessBuilder pb = new ProcessBuilder("jboss-cli.bat", "--connect", "--command=deploy --force C:\\Users\\jmartin5\\git\\ecommerce\\ECommerce\\build\\libs\\ECommerce.ear");