1. Introduction

In this tutorial, we’re going to have a look at how to deploy a war file on the JBoss server.

We can deploy the war file either by placing the file in the suitable directory manually or directly from Eclipse.

2. Deploying the WAR File by Hand

If we already have the war file and we want to deploy it on JBoss, we can go to the JBoss installation directory at standalone/deployments and paste the file there.

There are two modes in which the deployment works:

  • manual: the deployment scanner will not attempt to directly monitor the deployment folder. Instead, the scanner relies on marker files. The user’s addition of a marker file serves as a sort of command telling the scanner to deploy content.
  • auto: the scanner will directly monitor the deployment folder, automatically deploying new content and redeploying content whose timestamp has changed.

We can specify the mode in the configuration file standalone.xml by setting the value of the auto-deploy-zipped attribute to either true or false:

<deployment-scanner 
  name="default" 
  path="deployments" 
  scan-enabled="true" 
  scan-interval="5000" 
  relative-to="jboss.server.base.dir" 
  auto-deploy-zipped="true" 
  deployment-timeout="60"/>

By default, the value is true. So whenever we place a war file in the deployment folder, it’s deployed automatically. JBoss creates the .deployed marker file automatically which indicates that the content has been deployed.

However, if we remove the previous deployment before copying a new war file to the deployment folder, JBoss will create an .undeployed marker file suggesting that the deployment has been removed. In that case, we would need to delete the marker file manually for the deployment to begin.

If the value of auto-deploy-zipped is set to false, we’ll need to create the .deployed marker file manually for the deployment to start.

3. Using Eclipse to Deploy

We can create a dynamic web project in Eclipse, add a JBoss server and then configure the application to run on the server. Internally, Eclipse will create the war file of the application and place it in the JBoss directory. We can create an index.html file and set the welcome-file in web.xml to point to it.

To test if the application is deployed successfully we can fire up the web browser and try to access the URL in this format: http://localhost:/

If we see the index page, the application is deployed successfully.

4. Conclusion

In this article, we looked at how to deploy a war file on a JBoss server by working with the deployment folder and using Eclipse.

We also discussed the auto and manual deployment modes and how they work with JBoss’ marker files.