Site icon akquinet AG – Blog

Shrinking patched JBoss EAP server to a reasonable size

As explained in the blog entry Upgrading and patching the Red Hat JBoss Enterprise Application Platform JBoss EAP offers the possibility to conveniently update the server installation with the latest patches.
However, the way this is implemented leaves all previous versions and patches of your modules behind. I.e., older versions of the JAR files will not be used anymore, but just waste disk space. This is desirable only, if you want to have the possibility to roll back a patch later on or would like to keep track of the patch history.
To give you some numbers: The current EAP 6.4 server has an initial size of 166MB, but grows to a size of 509MB when updated to version 6.4.4. In this article we’d like to show you how to remove all unused garbage from the installation.

Step 1: Delete installation directory

We are starting from a freshly patched JBoss server in directory JBOSS_HOME (version 6.4.4). The first thing that safely can be deleted is the installation directory JBOSS_HOME/.installation. That’s just the place where the patch command unzips the patch files and stores the patch history.

Step 2: Update modules

JBoss stores the updated module versions in a hidden directory named JBOSS_HOME/modules/…/.overlays and JBOSS_HOME/bundles/…/.overlays, respectively. For example, you will find the current JARs of the Hibernate Core in JBOSS_HOME/modules/system/layers/base/.overlays/layer-base-jboss-eap-6.4.4.CP/org/hibernate/main. The magic is that the server will at runtime look into the overlays directory and ignore the initially installed modules.

So all you have to do is copy the updated modules into the JBOSS_HOME/…/modules directory and afterwards remove the overlays directory. Since this quite cumbersome to do manually I wrote a little shell script which you will find at the end of this blog.

Step 3: Update two module.xml files manually

Lastly, you will have to shorten some path definitions in the module.xml files with a text editor. Currently, this is necessary for two modules:  “” and “org.hornetq”.

Simply open JBOSS_HOME/modules/system/layers/base/org/jboss/as/web/main/module.xml and change the line
<resource-root path=”../../../../../../../org/jboss/as/web/main/lib”/
<resource-root path=”../../../../../org/jboss/as/web/main/lib”/>
The same applies for JBOSS_HOME/

Step 4: Delete/update unnecessary/recreated files (Optional)

In order to create a really clean distribution you might also want to delete the runtime directories in JBOSS_HOME/standalone, namely
log/, data/ and tmp/

Take a look at JBOSS_HOME/standalone/configuration/, too: The file probably contains a hardcoded handler.FILE.fileName property which may lead to confusing messages on another machine.


Here’s the Shell script:
It will not directly delete unnecessary directories but rename them with a XXX_DELETEME suffix.

After execution of the script and the manual edits try to start the server and if that is successful you can delete all unused files running:

         rm -r `find jboss-eap-6.4.4.GA -name \*XXX_DELETEME`

Exit mobile version