How to configure a custom JBoss deployment directory

Deploying applications to WildFly is can be achieved through management instruments or by deploying the artifacts in the deploy directory.

See the following tutorial to learn more about about both approaches:  How to deploy applications on WildFly

In this tutorial we are going to show how to provide a custom directory or URL for deploying your WildFly applications. We will show all the application server possible variants

Configuring a custom deployment directory can be done in different ways according to your application server version .

Configuring WildFly deploy directory

WildFly deployment scanner is configured into the deployment-scanner subsystem. By default, when running in standalone mode applications are automatically deployed when dropped into the “deployments” folder:

<subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">
    <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" runtime-failure-causes-rollback="${jboss.deployment.scanner.rollback.on.failure:false}"/>
</subsystem>

In the following example, we have defined a new relative path as system variable and we use it in the deployment-scanner path:

<system-properties>
        <property name="deploy.dir" value="/home/user"/>
</system-properties>

. . . . .

<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
            <deployment-scanner path="deployments" relative-to="deploy.dir" scan-interval="5000"/>
</subsystem>

In this case, application archives dropped into the /home/user/deployments path will be automatically deployed.

Configuring JBoss deploy directory in 6.x release

If you are using JBossAS-6, you can define a new deployment directory by adding it to the ProfileService bootstrap process. This will automatically pick up the specified directory and treat it as if you would put the content to the deploy/ folder.

Note that all specified folders need to be fully qualified url. So for example if you want to set the folder /home/user1 as deployment folder, you have to set is as file:///home/user1

So, in order to do that, you would need to edit the JBOSS_HOME/<servername>/conf/bootstrap/profile.xml. Find the  UserProfileFactory bean in that file.

<bean name="UserProfileFactory"
class="org.jboss.system.server.profileservice.bootstrap.StaticClusteredProfileFactory">
  <property name="confURI">${jboss.server.config.url}</property>
  <property name="deployersURI">${jboss.server.home.url}deployers</property>
  <property name="applicationURIs">
    <list elementClass="java.net.URI">
        <value>${jboss.server.home.url}deploy</value>
        <value>file:///home/user1 </value>
    </list>

. . . .
</bean>

Configuring JBoss deploy directory in 5.1 release

When using JBoss 5.1 your configuration file  will be server/xxxx/conf/bootstrap/profile.xml. Find the Bean named BootstrapProfileFactory and add your deploy folder to the list element:

<bean name="BootstrapProfileFactory"
     class="org.jboss.system.server.profileservice.repository.StaticProfileFactory">
     <property name="bootstrapURI">${jboss.server.home.url}conf/jboss-service.xml</property>
     <property name="deployersURI">${jboss.server.home.url}deployers</property>
     <property name="applicationURIs">
          <list elementClass="java.net.URI">
               <value>${jboss.server.home.url}deploy</value>

               <!-- Add your own deploy folder -->
               <value>file:/C:/JBossdeploy</value>
          </list>
     </property>
     ...
</bean>

In this example, we’re adding the folder C:/JBossdeploy to the list of scanning directories.

Configuring JBoss deploy directory in 4.x release

The configuration file which we need to modify is server/xxxx/conf/jboss-service.xml

Open it and move almost at the end of the file. There you’ll find the following attribute:

<attribute name="URLs">
     deploy/
</attribute>

This is the list of scanned deployment directories. Supposing you want to add a secondary deployment directory in /var/deploy filesystem, you have to add:

<attribute name="URLs">
     deploy/
     file:/var/deploy/
</attribute>

You can even choose to deploy a specific application from a remote repository. For example, if you have a remote server which has a virtual path “deploy” under the Base directory, then you can use this path as repository for deploying your application named myapp.ear:  http://www.remoteserver.com/deploy/myapp.ear

Good deployment!

Found the article helpful? if so please follow us on Socials