Tuesday, April 16, 2013

Run multiple instances of JBoss AS7 on the same machine (Mac + Linux)

NOTE: This tutorial assumes you have a working JBoss server running on port 8080.

1. Copy your existing JBOSS directory and rename it to jboss_maint (or something similar)

2. Go inside the jboss_maint/standalone/standalone.xml file. Find the <management-interface> element in the files. It looks something like the followings:

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="management-native" interface="management" port="${jboss.management.https.port:9999}"/>
<socket-binding name="management-http" interface="management" port="${jboss.management.https.port:9990}"/> 
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9443}"/> 
<socket-binding name="ajp" port="8009"/> 
<socket-binding name="http" port="8080"/> 
<socket-binding name="https" port="8443"/> 
<socket-binding name="osgi-http" interface="management" port="8090"/> 
<socket-binding name="remoting" port="4447"/>
<socket-binding name="txn-recovery-environment" port="4712"/> 
<socket-binding name="txn-status-manager" port="4713"/>
<outbound-socket-binding name="mail-smtp"> 
<remote-destination host="localhost" port="25"/> 
As you can see above, the public interface is being used as the default interface (In case you are interested, the definition of the public interface resides in <interface> element inside the same file).

Since we are using the same IP address for both maintenance and development servers, we only need to offset all ports to 100. You can achieve this via changing the port-offset attribute of <socket-binding-group> property:

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:100}">
Save the changes, go inside your jboss_maint/bin directory:

cd server/jboss_maint/bin
Start up your new server:

Now you should be able to browse to localhost:8180 and see the index page of JBOSS AS7. (Remember that 8080 plus the preset offset value (100) equals 8180).