The AS7 book!

JBoss Tuning

JBoss 5 book

No Registration required. Use your FB account to add comments to articles.

Twitter Button

Poll

Which is your favourite JSF library?
 
Top Programming Sites
Home JBoss AS JBoss deployment directory configuration

JBoss deployment directory configuration

  

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 6.0 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 6.0 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.0 release

 

JBoss 5.x doesn't use any more the older jboss-service.xml for configuring the deployment directory. Instead, you have to manipulate the server/xxx/conf/bootstrap/profile-repository.xml file.
Search for the SerializableDeploymentRepositoryFactory (about at the beginning of the file).

There, if you want to add for example the "deployments" beneath the JBoss Home, simply add another element in the array:

<bean name="SerializableDeploymentRepositoryFactory" class="org.jboss.system.server.profileservice.repository.SerializableDeploymentRepositoryFactory">
      <property name="storeRoot">${jboss.server.base.dir}</property>
      <property name="attachmentsRoot">${jboss.server.data.dir}/attachments</property>
      <property name="applicationURIs">
         <array elementClass="java.net.URI">
            <value>${jboss.server.home.url}deploy</value>
            <value>file:/C:/jboss-5.0.0.GA/deployments</value>
            
         </array>
      </property>
      <property name="serializer"><inject bean="AttachmentsSerializer"/></property>
      <property name="deploymentFilter"><inject bean="DeploymentFilter" /></property>
      <property name="hotDeploymentFilter">
        <bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter"/>
      </property>
      <property name="mainDeployer"><inject bean="MainDeployer"/></property>
      <depends>ProfileServicePersistenceDeployer</depends>
</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!