JBoss deployment directory configuration

User Rating: 4 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Inactive
 

JBoss_appiconIn this tutorial we are going to show how to provide an alternative directory or URL for deploying your JBoss applications. We will show all the possible variants (from the release 4.x to the newer 7.x release of the AS).

Deploying applications to JBoss is a simple task: all you do to deploy an application in JBoss is dropping the archive into the deploy directory. The JBoss engine immediately inspects the contents of the archive and attempts to deploy the component(s). Undeploying is as easy as deleting the archive from the deploy directory.

Sometimes it can be convenient to deploy your applications in another directory or filesystem. Configuring another deploy directory in JBoss is different from one version to another:

Configuring JBoss deploy directory in 7.x release

JBoss AS 7 deployment scanner is configured into the deployment-scanner:1.1 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:1.1">
            <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000"/>
</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!

Related articles available on mastertheboss.com

How to configure JBoss to disable hot deployment ?

On JBoss AS 7 and WildFly the default rule is that archived appli

How do I make sure my MBean is deployed after my EJB ?

  If your MBean is dependant on another resource, supposing cont

How do I change the default lib directory in an ear file?

  Supposing you have an Enterprise application which has been pa

How to let JBoss deploy an application after other apps?

  If you are running JBoss AS 7 or WildFly check the following t

How to deploy an application temporarly with JBoss ?

One way to do it, is using the jboss.system:service=MainDeployer

How to add a custom JBoss archive in an Ear ?

JBoss custom archives (like .sar or .har) are not recognized by t