Tuesday, May 29, 2012

JBoss Command-line Deploy/Undeploy

I was creating a Chef cookbook to deploy a .war file to JBoss AS 7.1. One iteration of refactoring had me using the command-line tools provided with JBoss to do the deploy/undeploy. Ultimately, I didn't use this method, but wanted to document it in case I change my mind later.

I am using Bryan Berry's JBoss cookbook to configure my base JBoss install, which installs JBoss to /usr/local/jboss. I am also using the full-ha profile for the standalone JBoss configuration.


  • CONTROLLER: the IP address bound to JBoss. I used Vagrant in this example, so the IP is an arbitrary static IP address that I chose, e.g.
  • USER: the user to connect to the JBoss controller (you set this up with the add-user.sh script in JBOSS_HOME/bin)
  • PASSWORD: the password to connect to the JBoss controller with

The jboss-cli.sh script allows you to run in non-interactive mode. You must pass the JBoss commands along the command line as an argument, but if you have spaces in your command, then you have to put your commands in a file and use the --file switch to indicate the file containing your commands.

Here is a sample file, e.g. /tmp/jboss-deploy-command (should be one command per line):


In my example, I'm deploying an expanded archive as a directory, so the "archive" => false attribute must be present.

The command to execute for deploying MyWebApp.war is:

$ /usr/local/jboss/default/bin/jboss-cli.sh --controller=${CONTROLLER}:9999 --connect --user=${USER} --password=${PASSWORD} --file=/tmp/jboss-deploy-command

If all goes well, you will see this output:

{"outcome" => "success"}


Removing the web app is simple:

$ /usr/local/jboss/default/bin/jboss-cli.sh --controller=${CONTROLLER}:9999 --connect --user=${USER} --password=${PASSWORD} --command=/deployment=MyWebApp.war:remove

See also: https://community.jboss.org/message/630853.

No comments:

Post a Comment