Version 18

    Setting up multiple instances of JBoss on the same machine

     

    The ServiceBindingManager

     

    JBoss 5

     

    Easy Way

     

    Start JBoss with the VM parameter jboss.service.binding.set set to either ports-default, ports-01, ports-02 etc. For example:

     

    run -Djboss.service.binding.set=ports-01

     

    The advantage of this way is you don't have to take (and maintain) a separate copy of the all folder if you want to, say, start up multiple instances of JBoss running as a cluster.

     

    Harder Way

     

    Edit server/default/conf/bindingservice.beans/META-INF/bindings-jboss-beans.xml

     

    Change "ports-default":

    <!-- The name of the set of bindings to use for this server -->
    <parameter>${jboss.service.binding.set:ports-default}</parameter>
    

     

    To any of the defined port sets. JBoss 5 ships with 4 pre defined port sets. You can find them defined further down in the bindings.xml file.

    <!-- The ports-01 bindings are obtained by taking the base bindings and adding 100 to each port value -->
       <bean name="Ports01Bindings" class="org.jboss.services.binding.impl.ServiceBindingSet">
          <constructor>
             <!--  The name of the set -->
             <parameter>ports-01</parameter>
             <!-- Default host name -->
             <parameter>${jboss.bind.address}</parameter>
             <!-- The port offset -->
             <parameter>100</parameter>
             <!-- Set of bindings to which the "offset by X" approach can't be applied -->
             <parameter><null/></parameter>
          </constructor>
       </bean>
    

     

    In this case lets change it to use the ports-01 set.

    <!-- The name of the set of bindings to use for this server -->
    <parameter>${jboss.service.binding.set:ports-01}</parameter>

     

    If you familiarize yourself with this configuration file you should find it easy to create you own port sets.

     

    Previous versions of JBoss

     

    In conf/jboss-service you will find the binding manager.

       <!-- 
          | Binding service manager for port/host mapping. This is a sample
          | config that demonstrates a JBoss instances with a server name 'ports-01'
          | loading its bindings from an XML file using the ServicesStoreFactory
          | implementation returned by the XMLServicesStoreFactory.
          |
          | ServerName: The unique name assigned to a JBoss server instance for
          | lookup purposes. This allows a single ServicesStore to handle mulitiple
          | JBoss servers.
          |
          | StoreURL: The URL string passed to org.jboss.services.binding.ServicesStore
          | during initialization that specifies how to connect to the bindings store.
          | StoreFactory: The org.jboss.services.binding.ServicesStoreFactory interface
          | implementation to create to obtain the ServicesStore instance.
    
       <mbean code="org.jboss.services.binding.ServiceBindingManager"
         name="jboss.system:service=ServiceBindingManager">
         <attribute name="ServerName">ports-01</attribute>
         <attribute name="StoreURL">../docs/examples/binding-manager/sample-bindings.xml</attribute>
         <attribute name="StoreFactoryClassName">
           org.jboss.services.binding.XMLServicesStoreFactory
         </attribute>
       </mbean>
    
       -->
    

     

    Uncomment this to use the ports-01 settings from the example bindings.

    The example contains 4 different ports settings besides the default settings (which is really unecessary).

     

    Doing it by hand

     

    Thanks to Daniel Kha for this guide

     

    It is possible to setup a second instance of JBoss 3.0.6 (or 3.2.0) on the same machine simply by changing the ports of the 2nd installation of JBoss.  I believe this would also work for more than 2 instances.  In brief, to get my second JBoss installation to run, in most of the files I changed the ports by prepending an extra "1" to the default port numbers resulting in ports in the ~10000 range.

     

    I've made some changes so you might want to go over this again depending on the last modified date (see bottom).

     

    The following was written primarily for JBoss 3.0.6.  Updates were done for JBoss 3.2.0 (noted in steps where it's different between the versions).

    Update 2006-02-14: Locations of the files in JBoss-4.0.4RC1 (and probably other versions of jboss4) were added.

     

    JBoss Configuration Files to Change:

     

    1.  In <jboss_home>/server/all/conf/jboss-service.xml (4.0.4rc1: deploy/dynclassloader-service.xml for WebService, deploy/naming-service.xml for NamingService, deploy/invokers-service.xml for JRMPInvoker), edit the following:

     

    - For the mbean org.jboss.web.WebService, change the port setting line to (8083 is the default):

    <attribute name="Port">18083</attribute>

     

    - For the mbean org.jboss.naming.NamingService, change the port setting line to (1099 is the default):

    <attribute name="Port">11099</attribute>

     

    - For the mbean org.jboss.invocation.jrmp.server.JRMPInvoker, change the port setting line to (4444 is the default):

    <attribute name="RMIObjectPort">14444</attribute>

     

     

    2.  In <jboss_home>/server/all/deploy/cluster-service.xml (4.0.4rc1: could not find this one), edit the following:

     

    - For the mbean org.jboss.ha.jndi.HANamingService, add this port setting (1100 is the default so I just prefixed an extra "1"):

    <attribute name="Port">11100</attribute>

     

    - Also for the mbean org.jboss.ha.jndi.HANamingService, add this port setting (0 is the default, I just made it 19000 to keep things sort of consistent with the above):

    <attribute name="RmiPort">19000</attribute>

     

     

    3.  In <jboss_home>/server/all/deploy/jbossmq-service.xml (4.0.4rc1: could not find the first one, deploy/jms/uil2-service.xml for UILServerILService), edit the following:

     

    - For the mbean org.jboss.mq.il.oil.OILServerILService, change the port setting line to (8090 is the default):

    <attribute name="ServerBindPort">18090</attribute>

     

    - For the mbean org.jboss.mq.il.uil.UILServerILService, change the port setting line to (8091 is the default):

    <attribute name="ServerBindPort">18091</attribute>

     

    For JBoss 3.2.0, also do these steps (contributed by Anantha Krishnan V):

     

    3.a In <jboss_home>/server/all/deploy/jbossmq-service.xml, edit the following:

     

    - For the mbean org.jboss.mq.il.oil2.OIL2ServerILService, change the port setting line to (8092 is the default):

    <attribute name="ServerBindPort">18092</attribute>

     

    - For the mbean org.jboss.mq.il.uil2.UILServerILService, change the port setting line to (8093 is the default):

    <attribute name="ServerBindPort">18093</attribute>

     

     

    4.  In <jboss_home>/server/all/deploy/hsqldb-service.xml, edit the following:

     

    - For the mbean org.jboss.jdbc.HypersonicDatabase, change the port setting line to (1476 is the default):

    <attribute name="Port">11476</attribute>

     

    - For the mbean org.jboss.resource.connectionmanager.RARDeployment, change the ConnectionURL property to reflect the new port setting line (1476 is the default):

    <config-property name="ConnectionURL" type="java.lang.String">jdbc:hsqldb:hsql://localhost:11476</config-property>

     

    For JBoss 3.2.0, do these steps (contributed by Anantha Krishnan V):

     

    4.a In <jboss_home>/server/all/deploy/hsqldb-ds.xml, edit the following:

     

    - For the mbean org.jboss.jdbc.HypersonicDatabase, change the port setting line to (1701 is the default):

    <attribute name="Port">11701</attribute>

     

    - Change the local-tx-datasource to reflect the new port setting line (1701 is the default):

    <connect-url>jdbc:hsqldb:hsql://localhost:11701</connect-url>

     

     

    5.  In <jboss_home>/server/all/deploy/jbossweb.sar/META-INF/jboss-service.xml, edit the following:

     

    - Under the "Configure the Request Listeners" section, look for the add listener call of "org.mortbay.http.SocketListener" and change the port setting line to (8080 is the default):

    <Set name="Port"><SystemProperty name="jetty.port" default="18080"/></Set>

     

    - Under the "Configure the Request Listeners" section, look for the add listener call of "org.mortbay.http.ajp.AJP13Listener" and change the port setting line to (8009 is the default):

    <Set name="Port">18009</Set>

     

    - Also the call "org.mortbay.http.ajp.AJP13Listener", change the port setting line to (443 is the default):

    <Set name="confidentialPort">1443</Set>

     

    For JBoss 3.2.0, do these steps (contributed by Anantha Krishnan V):

     

    5.a In <jboss_home>/server/all/deploy/jbossweb-jetty.sar/META-INF/jboss-service.xml, edit the following:

     

    - Do the same as above, since the .sar was renamed.

     

    For JBoss 3.2.1 with Tomcat, do these steps:

     

    5.b In <jboss_home>/server/all/deploy/jbossweb-tomcat.sar/META-INF/jboss-service.xml, edit the following:

     

    - Under the "Configure the Request Listeners" section, look for the add listener call of "org.apache.coyote.tomcat4.CoyoteConnector" and change the port setting line to (8080 is the default):

    <!-- A HTTP/1.1 Connector on port 18080 --><Connector className="org.apache.coyote.tomcat4.CoyoteConnector"                port="18080" minProcessors="3" maxProcessors="10"                enableLookups="true" acceptCount="10" debug="0"                connectionTimeout="20000" useURIValidationHack="false" />

     

    - Also the AJP 1.3 Connector, change the port setting line to (8009 and 8443 are the defaults):

    <!-- A AJP 1.3 Connector on port 18009 -->            <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"                port="18009" minProcessors="5" maxProcessors="75"                enableLookups="true" redirectPort="18443"                acceptCount="10" debug="0" connectionTimeout="20000"                useURIValidationHack="false"                protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>

     

    6.  In <jboss_home>/server/all/deploy/jmx-rmi-adaptor.sar/META-INF/jboss-service.xml, edit the following:

     

    - For the mbean org.jboss.jmx.adaptor.rmi.RMIAdaptorService, change the port setting line to (0 is the default, but I made it 19001 since we already used 19000):

    <attribute name="RMIObjectPort">19001</attribute>

     

     

    7.  In <jboss_home>/server/all/conf/jacorb.properties, edit the following (if you are using JBoss 3.0.6):

     

    - For the line OAPort=n, change the port setting line to (3528 is the default):

    OAPort=13528

     

     

    8.  Now execute the run.bat or run.sh script from the

    /bin directory in each of the JBoss instances (in sequence, one after the other) and things should work!

     

     

    To shutdown the different instances:

     

    1.  Execute the shutdown.bat or shutdown.sh script from the

    /bin directory with 2 extra arguments.  The first argument is the hostname and the second is the port number.

     

    In our example you would shutdown the JBoss instance that is configured with default ports using this command:

    <jboss_home>\bin\shutdown.bat -s jnp://localhost:11099 -u <username> -p <password>

     

    And for the second instance with the modified ports, use this command:

    <jboss_home>\bin\shutdown.bat -s jnp://localhost:11199 -u <username> -p <password>

     

    Note: The port will be each binding port that was specified for jboss:service=Naming

     

    Note: UNIX users use shutdown.sh.