Occasionally, it’s useful to run multiple JBoss instances on one machine. Like with any network server, this is difficult because only one application can bind to a port at any given time. You have to assign different sets of ports to each instance. JBoss consists of quite a few network services so it’s a lot of tedious work to reconfigure each and every port (I counted 16 different ports on JBoss 6’s default profile).
Fortunately, there’s a little known but documented mechanism to globally remap all JBoss ports. The file
server/default/conf/bindingservice.beans/META-INF/bindings-jboss-beans.xml (for the default profile) contains port bindings that you can activate using the
jboss.service.binding.set property from the command line.
Suppose there’s already a JBoss instance running (which uses the default
ports-default binding). Using the command line property, we can run a second instance like this:
ports-01 binding adds 100 to each port of the
ports-02 adds 200, and
ports-03 adds 300. You can easily add more ports bindings yourself if you need them.
I tested this on JBoss 6.0.0.Final and it worked well. An alternative to port mapping approach is to make your machine listen on multiple IP addresses and have each JBoss instance bind to a different IP address using the
jboss.bind.address property. Obviously, this requires no port remapping but changes to your network setup, usually including DNS.