By default JBoss requires a number of work/tmp directories to be available at runtime.
For example work, tmp, data and log are created and used under the running profile to store application data, compiled JSPs, transaction details and log files.
By default it is assumed that these directories will have the jboss-as/server/profile directory as its parent.
However it is possible to take these working directories and relocate them outside of the standard JBoss directory structure.
To relocate the logging directory specify the new location via the following system property
-Djboss.server.log.dir=/tmp/prod/log
To relocate the data directory specify the new location via the following system property
-Djboss.server.data.dir=/tmp/prod/data
To relocate the tmp directory specify the new location via the following system property
-Djboss.server.temp.dir=/tmp/prod/data
1. Gotchas
Unfortunately its not just as easy as specifying system properties. Some xml configuration changes are also required.
In the jboss-as/server/profile/conf/jboss-service.xml file, edit XML configuration for the following mbean to specify the location of its data directory
<mbean code="org.jboss.system.pm.AttributePersistenceService"
name="jboss:service=AttributePersistenceService"
xmbean-dd="resource:xmdesc/AttributePersistenceService-xmbean.xml">
<!-- the AttributePersistenceService is persistent, itself -->
<attribute name="AttributePersistenceManagerClass">org.jboss.system.pm.XMLAttributePersistenceManager</attribute>
<attribute name="AttributePersistenceManagerConfig">
<data-directory>file://${jboss.server.data.dir}/xmbean-attrs</data-directory>
</attribute>
<attribute name="ApmDestroyOnServiceStop">false</attribute>
<attribute name="VersionTag"></attribute>
</mbean>
The directory mbean-attrs directory has to exist within the directory or the container will fail to start.
The embedded Tomcat instance also has to be informed of the location of where it has to store its compiled JSP pages. This is done by editing the jboss-as/server/noc-default/deploy/jbossweb.sar/server.xml and the workDir attribute
<Host name="localhost" workDir="${jboss.server.work.dir}">
Finally run JBoss with the required system properties
./run.sh -c prod -Djboss.server.data.dir=/tmp/prod/data -Djboss.server.temp.dir=/tmp/prod/tmp -Djboss.server.log.dir=/tmp/prod/log -Djboss.server.work.dir=/tmp/prod/work