Deploying and Undeploying farmed applications using JMX
You setup a JBoss cluster and want to deploy applications to it. If you copy an application into the JBoss "farm" folder, the application archive will deploy locally and then be pushed to all other (running) cluster nodes. When other nodes join the cluster, they will pull the application to their farm deployment folder and deploy it. This process is called Farming . But how do you do this "farm deployment" using the JMX console? This WIKI explains exactly that.
Setting up additional "farm" folders
When JBoss is first installed, with the "all" configuration, you get a folder called "farm". What if you want your application to be independently "farmed" rather than having all applications deployed to this farm directory? You can create additional farming folders where you can distribute your applications to the cluster independtly and without conflicting with the deployment of other applications. Here is how to do it:
Create a new folder "myappfarm" under <jboss-install-directory>/server/<node-name>.
Add this folder name to the farm-service.xml file found under <jboss-install-directory>/server/<node-name>/deploy/deploy.last
<attribute name="URLs"> farm/,myappfarm/ </attribute>
Repeat the above two steps to all other nodes in your cluster.
Now restart the nodes in the cluster.
Now your directory "myappfarm" becomes a "farm" folder and behaves exactly like the farm folder.
Copy your application into the "myappfarm" folder in any one of the nodes and there will be a cluster-wide push and the application will get deployed in all nodes in the cluster.
Once the "myappfarm" directory is setup you can have your application archive here and do a hot-deploy using the following steps through JMX console.
Open the JMX console and locate the FarmMemberService MBean. Optionally you can copy paste this url (change the ip and port to point to any one of the nodes in your cluster) FarmMemberService in your localhost .
Locate the method removeURL() in this console and provide the url as "file:/<jboss-install-directory>/server/<node-name>/myappfarm/". Instantly your application will be undeployed from the cluster. However, the archive will not be deleted. So you can update the archive or momentarily stop the application from running in the cluster using this technique.
Locate the method addURL() in the JMX console and provide the url as "file:/<jboss-install-directory>/server/<node-name>/myappfarm/". Instantly your application will be deployed from the "myappfarm" folder. Whatever archives have been added to that folder will be instantly deployed across the farm.