Advertise with us

Our eBooks

Clustering JBoss AS 7

Important Notice: There is a more updated tutorial about Clustering with WildFly Application Server: Clustering WildFly Application Server

In this article we will show how to configure in a nutshell JBoss AS 7 for clustering. Then we will deploy a sample Java EE 6 application on the top of it.

Earlier JBoss users used to start a clustered server configuration by feeding the -c all parameter to the application server starter shell.

The AS 7 is pretty different from other server releases as it does not contain multiple server configuration directories (all, default, minimal ..). It just contains a set of configuration files each one including a different set of server modules.

The built-in cluster configuration file are standalone-ha.xml and standalone-full-ha.xml (the latter one including Corba support). So let’s start a demo cluster configuration composed of two nodes on the same machine.

So unzip two AS 7 distribution on a path of your choice, for example:


In order to start your cluster nodes you need to provide an unique node name and, since you are running multiple servers on the same machine specify a port offset so that you don’t have port conflicts between servers.

So we will start up NodeA with:

standalone -c standalone-ha.xml					

and NodeB with:

standalone -c standalone-ha.xml -Djboss.socket.binding.port-offset=100						

Fine. Checkout the welcome page to see that everything works correctly:
http://localhost:8080 (nodeA) and http://localhost:8180 (nodeB)

Configuring Apache Web server to reach JBoss AS 7 cluster

There are more than one available choice to connect a Web server in front of JBoss AS 7 cluster. You can either choose the older mod_jk approach which provides a static view of your AS 7 cluster or, as we suggest, configure mod_cluster which provides additional advantages such as:

  • Dynamic configuration of httpd workers
  • Server-side load balance factor calculation
  • Fine grained web-app lifecycle control

Mod_cluster Java libraries are built-in into JBoss AS 7 distribution so you don't need to hack your server release. On the other hand, you need to add to your Apache server the native libraries required to proxy calls to JBoss AS. Download the latest mod_cluster binaries at:

 The above modules can be found into the mod_cluster distribution under httpd/modules path. You have to place them into the Apache's module folder.

Then we edit httpd.conf. We should add the modules:

LoadModule slotmem_module modules/
LoadModule manager_module modules/
LoadModule proxy_cluster_module modules/
LoadModule advertise_module modules/

Also, please note we should comment out:

#LoadModule proxy_balancer_module modules/                    

This one conflicts with cluster module. And then we need to make httpd to listen to public address so we could do the testing. Because we installed httpd on host we will use the following available port:


    <Directory />     
      Order deny,allow     
      Deny from all     
      Allow from 192.168.1.  

  KeepAliveTimeout 60
  MaxKeepAliveRequests 0  
  ManagerBalancerName mycluster
  AdvertiseFrequency 5

Now verify that the Apache JBoss connection works properly by typing:

© 2021 All Rights Reserved.

Please publish modules in offcanvas position.