How to run multiple instances of JBoss, JBoss multinode / Clustered Deployment


***Running Multiple Instances of single/different JBoss on same machine ***

IMP Note - * This article is written considering JBoss 4.2.2 into account.
                       * For other versions, process may vary from little to a lot different, depending upon which version of JBoss you are dealing with.
                       * For running multiple instance JBoss in production environment, it needs to have good system resources, make sure you have them.


Many times there is a situation when we want to run same/different ear/war/jar (i.e. any java application), on same machine but as different instances so as to separate them all together.

So here are the steps for configuring your multi instance JBoss :- 

Prerequisites & Caution 
* JBoss's configuration profiles like default/all/minimal/production (whichever you use) configured properly as per your application needs.
* Multi-instance run for JBoss involves creating & running separate JVMs per instance.
* In Multi-instance run (on single machine & single JBoss), JBoss bin directory will be shared between all instances, so make proper arrangements/code changes to avoid unusual sharing between different JBoss instances.


Terms Used
a. %JBoss_Home% = path to your JBoss directory,
b. %JBoss Configuration profile% = Its a JBoss server configuration used, by default JBoss comes with four server configurations like all, default, production, minimal, etc. So this points to your configuration directory i.e. <%JBoss_Home%.>/server/<configuration_profile_folder>. e.g. C:\jboss-4.2.2.GA\server\default

Steps:- 
1) Create Copies of your JBoss configuration profile folder. e.g. copy-paste default configuration profile and rename it to some node name like node1,node2, etc   

It would look like - 


2) Go to conf directory inside your server profile directory i.e. "<%JBoss_Home %>/server/<% JBoss Configuration profile %>/conf/"


like - 

Open and edit jboss-service.xml
Search for "org.jboss.services.binding.ServiceBindingManager" which is  

<!-- ==================================================================== -->
   <!-- Service Binding                                                      -->
   <!-- ==================================================================== -->

   <!-- Automatically activated when generatting the clustering environment -->
   <!-- @TESTSUITE_CLUSTER_CONFIG@ -->

   <!--
      | 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">${jboss.home.url}/docs/examples/binding-manager/sample-bindings.xml</attribute>
     <attribute name="StoreFactoryClassName">
       org.jboss.services.binding.XMLServicesStoreFactory
     </attribute>
   </mbean>
   -->

Screen-shot - 






* Basically, it means, what is the port-binding-config-file location, and in that file, which port configuration to use for this server instance. Here ServerName, StoreURL are two properties which are important.

* By default, JBoss comes with default ports-binding-config-file, which is at location like <%Jboss_Home%>/docs/examples/binding-manager/sample-bindings.xml





3) This sample-bindings.xml file has a structure like - 

* Its ROOT tag is “service-bindings” which has as many “server” child tag as no of distinct server instances. e.g. If you have 3 server configurations/instances (e.g. node1, node2, node3) you can create three different “server” tags in above binding file and modify those accordingly to avoid port conflicts, when running all of them concurrently. (copy-paste complete “server” tag and modify accordingly for your instance)

* Each “server” tag has many “service-config” child tags, each specifying which service will run on which port (e.g. jndi,jmx,iiop,HA-JNDI,Java-Webservice,http,https services etc.)





File - sample-bindings.xml
<service-bindings>
          <server name="ports-default">
                   <service-config  ..…..>
                   ….
                   </service-config>
          ...
          ...
                   <service-config  ..…..>
                   ….
                   </service-config>
          </server>
          ...
          <server name="MyNode-portsConfig">
                   <service-config  ..…..>
                   ….
                   </service-config>
          ...
          ...
                   <service-config  ..…..>
                   ….
                   </service-config>
          </server>
          ...
</service-bindings>

So use the default sample-bindings.xml or create your own binding xml and put its location in jboss-service.xml's binding manager tag i.e. “ServiceBindingManager” mbean tag.

Here is a sample working binding file - 


Note - here, Http service port for port-default is 9080, for port-01 is 9180, for port-02 is 9280, and so on...
<!--
   $Id: sample-bindings.xml 63329 2007-06-04 09:56:26Z dimitris@jboss.org $

   A sample configuration for the binding service which defines different
   port configurations (ports-default, ports-01, ports-02) for running multiple
   JBoss instances in parallel on the same machine.

   The actual port configuration can be selected within the jboss-service.xml
   file via ServiceBindingManager attribute ServerName.

   The following sample e.g. selects the jboss-default port configuration

   <mbean code="org.jboss.services.binding.ServiceBindingManager"
          name="jboss.system:service=ServiceBindingManager">
      <attribute name="ServerName">ports-default</attribute>
      <attribute name="StoreURL">file:../server/port-bindings.xml</attribute>
      <attribute name="StoreFactoryClassName">
         org.jboss.services.binding.XMLServicesStoreFactory
      </attribute>
   </mbean>

   For running a second server instance you have to change the port
   bindings of that instance by specifing an alternative port binding
   configuration in the jboss-service.xml of the second server, e.g.

   <attribute name="ServerName">ports-01</attribute>

   Additional documentation for running multiple JBoss instances on the
   same machine can be found at http://www.jboss.com/products/jbossas/docs
   in the offical JBoss Application Server Guide in chapter
   "MBean Service Miscellany - Services Binding Management"
-->
<service-bindings>

   <!-- ********************************************************** -->
   <!-- *                        ports-default                   * -->
   <!-- ********************************************************** -->
   <server name="ports-default">

      <!-- ********************* jboss-service.xml ****************** -->

      <service-config name="jboss:service=Naming"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port" hostName="BindAddress">
            <attribute name="RmiPort">1098</attribute>
         </delegate-config>
         <binding port="1099" host="${jboss.bind.address}"/>
      </service-config>


      <service-config name="jboss:service=WebService"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="9083"/>
      </service-config>


      <service-config name="jboss:service=invoker,type=jrmp"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="RMIObjectPort"/>
         <binding port="4444"/>
      </service-config>

      <service-config name="jboss:service=invoker,type=pooled"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="ServerBindPort"/>
         <binding port="4445"/>
      </service-config>


      <!-- ********************* cluster-service.xml **************** -->

      <service-config name="jboss:service=HAJNDI"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="Port" hostName="BindAddress">
            <attribute name="RmiPort">1101</attribute>
         </delegate-config>
         <binding port="1100" host="${jboss.bind.address}"/>
      </service-config>

      <service-config name="jboss:service=invoker,type=jrmpha"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="RMIObjectPort"/>
         <binding port="4444"/>
      </service-config>

      <service-config name="jboss:service=invoker,type=pooledha"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="ServerBindPort"/>
         <binding port="4448"/>
      </service-config>

      <!-- ********************* iiop-service.xml ****************** -->

      <service-config name="jboss:service=CorbaORB"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="3528"/>
      </service-config>


      <!-- ********************* jmx-rmi-adaptor.sar **************** -->

      <service-config name="jboss.jmx:type=Connector,name=RMI"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="RMIObjectPort"/>
         <binding port="19001"/>
      </service-config>


      <!-- ********************* snmp-adaptor.sar ****************** -->

      <service-config name="jboss.jmx:name=SnmpAgent,service=trapd,type=logger"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="1162"/>
      </service-config>

      <service-config name="jboss.jmx:name=SnmpAgent,service=snmp,type=adaptor"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="1161"/>
      </service-config>


      <!-- ********************* jbossmq-service.xml **************** -->

      <!-- JMS related services -->
      <service-config name="jboss.mq:service=InvocationLayer,type=UIL2"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="ServerBindPort"/>
         <binding port="8093"/>
      </service-config>


      <!-- ********************* jbossmq-httpil.sar **************** -->
      <service-config name="jboss.mq:service=InvocationLayer,type=HTTP"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="URLPort"/>
         <binding port="9080"/>
      </service-config>

      <!-- ********************* hajndi-jms-ds.xml **************** -->

      <!-- The JMS provider loader -->
      <service-config name="jboss.mq:service=JMSProviderLoader,name=HAJNDIJMSProvider"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <!--
              MAKE SURE java.naming.provider.url
              PORT IS SAME AS HA-JNDI ABOVE !!!
         -->
         <delegate-config>
            <attribute name="Properties"><![CDATA[
                java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
                java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
                java.naming.provider.url=${jboss.bind.address:localhost}:1100
                jnp.disableDiscovery=false
                jnp.partitionName=${jboss.partition.name:DefaultPartition}
                jnp.discoveryGroup=${jboss.partition.udpGroup:230.0.0.4}
                jnp.discoveryPort=1102
                jnp.discoveryTTL=16
                jnp.discoveryTimeout=5000
                jnp.maxRetries=1
           ]]>
           </attribute>
        </delegate-config>
        <!-- NOTE: YOU MUST ADD THIS ELEMENT, BUT THE VALUE DOESN'T MATTER
             BE SURE THE CORRECT VALUE IS IN java.naming.provider.url ABOVE -->
        <binding port="1100"/>
      </service-config>

      <!-- **************** http-invoker.sar & httpha-invoker.sar*************** -->
      <!-- EJBInvoker -->
      <service-config name="jboss:service=invoker,type=http"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerServlet</attribute>
        </delegate-config>
         <!--
            MUST BE THE SAME AS
            TOMCAT HTTP CONNECTOR BELOW !!!
             -->
         <binding port="9080"/>
      </service-config>

      <!-- EJB3 Remoting Connector ejb3.deployer/META-INF/jboss-service.xml -->

      <service-config name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
        <delegate-config>
           <attribute name="InvokerLocator">socket://${jboss.bind.address}:3873</attribute>
        </delegate-config>
         <binding port="3873"/>
      </service-config>

        <!-- JMXInvoker -->
      <service-config name="jboss:service=invoker,type=http,target=Naming"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerServlet</attribute>
        </delegate-config>
         <!--
            MUST BE THE SAME AS
            TOMCAT HTTP CONNECTOR BELOW !!!
             -->
         <binding port="9080"/>
      </service-config>

        <!-- readonly JMXInvoker -->
      <service-config name="jboss:service=invoker,type=http,target=Naming,readonly=true"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/readonly/JMXInvokerServlet</attribute>
        </delegate-config>
         <!--
            MUST BE THE SAME AS
            TOMCAT HTTP CONNECTOR BELOW !!!
             -->
         <binding port="9080"/>
      </service-config>

    <!-- **************** httpha-invoker.sar*************** -->
      <!-- EJBInvokerHA -->
      <service-config name="jboss:service=invoker,type=httpHA"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerHAServlet</attribute>
        </delegate-config>
         <binding port="9080"/>
      </service-config>

      <!-- JMXInvokerHA -->
      <service-config name="jboss:service=invoker,type=http,target=HAJNDI"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerHAServlet</attribute>
        </delegate-config>
         <binding port="9080"/>
      </service-config>


    <!-- ********************* jboss-ws4ee.sar **************** -->

      <!-- Web Service related services -->
      <service-config name="jboss.ws4ee:service=AxisService"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
        <delegate-config portName="WebServicePort" hostName="WebServiceHost"/>
        <binding port="9080" host="${jboss.bind.address}"/>
      </service-config>

      <!-- ********************* remoting **************** -->

       <!-- *** remoting connector *** -->
       <service-config name="jboss.remoting:service=Connector,transport=socket"
          delegateClass="org.jboss.services.binding.XSLTConfigDelegate">
          <delegate-config>
             <xslt-config configName="Configuration"><![CDATA[
               <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

                  <xsl:output method="xml" />
                  <xsl:param name="port"/>

                  <xsl:template match="/">
                     <xsl:apply-templates/>
                  </xsl:template>

                  <xsl:template match="attribute[@name='serverBindPort']">
                     <attribute type="java.lang.String" name="serverBindPort"><xsl:value-of select='$port'/></attribute>
                  </xsl:template>

                  <xsl:template match="*|@*">
                     <xsl:copy>
                        <xsl:apply-templates select="@*|node()"/>
                     </xsl:copy>
                  </xsl:template>
               </xsl:stylesheet>
          ]]>
          </xslt-config>
          </delegate-config>
          <binding port="4446" />
       </service-config>


      <!-- ********************* hsqldb-ds.xml ********************** -->

      <!-- Hypersonic related services when using the tcp/ip access
      <service-config name="jboss.jca:service=ManagedConnectionFactory,name=DefaultDS"
         delegateClass="org.jboss.services.binding.XSLTConfigDelegate"
      >
         <delegate-config>
         <xslt-config configName="ManagedConnectionFactoryProperties"><![CDATA[
<xsl:stylesheet
      xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

  <xsl:output method="xml" />
  <xsl:param name="host"/>
  <xsl:param name="port"/>

  <xsl:template match="/">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="config-property[@name='ConnectionURL']">
    <config-property type="java.lang.String" name="ConnectionURL">jdbc:hsqldb:hsql://<xsl:value-of select='$host'/>:<xsl:value-of select='$port'/></config-property>
  </xsl:template>

  <xsl:template match="*|@*">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
]]>
         </xslt-config>
         </delegate-config>
         <binding host="localhost" port="1701" />
      </service-config>

      <service-config name="jboss:service=Hypersonic"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
      >
         <delegate-config portName="Port" />
         <binding port="1701" />
      </service-config>
      -->


      <!-- ********************* tomcat ********************** -->

      <service-config name="jboss.web:service=WebServer"
         delegateClass="org.jboss.services.binding.XSLTFileDelegate"
         >
         <delegate-config>
            <xslt-config configName="ConfigFile"><![CDATA[
   <xsl:stylesheet
         xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

     <xsl:output method="xml" />
     <xsl:param name="port"/>

     <xsl:variable name="portAJP" select="$port - 71"/>
     <xsl:variable name="portHttps" select="$port + 363"/>

     <xsl:template match="/">
       <xsl:apply-templates/>
     </xsl:template>

      <xsl:template match = "Connector">
         <Connector>
            <xsl:for-each select="@*">
            <xsl:choose>
               <xsl:when test="(name() = 'port' and . = '9080')">
                  <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute>
               </xsl:when>
               <xsl:when test="(name() = 'port' and . = '8009')">
                  <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute>
               </xsl:when>
               <xsl:when test="(name() = 'redirectPort')">
                  <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute>
               </xsl:when>
               <xsl:when test="(name() = 'port' and . = '8443')">
                  <xsl:attribute name="port"><xsl:value-of select="$portHttps" /></xsl:attribute>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
               </xsl:otherwise>
            </xsl:choose>
            </xsl:for-each>
            <xsl:apply-templates/>
         </Connector>
      </xsl:template>

     <xsl:template match="*|@*">
       <xsl:copy>
         <xsl:apply-templates select="@*|node()"/>
       </xsl:copy>
     </xsl:template>
   </xsl:stylesheet>
   ]]>
            </xslt-config>
         </delegate-config>
         <binding port="9080"/>
      </service-config>

      <!-- ********************* jboss messaging ********************** -->

      <service-config name="jboss.messaging:service=Connector,transport=bisocket"
                      delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config>
            <attribute name="Configuration"><![CDATA[
               <config>
                  <invoker transport="bisocket">
                     <attribute name="marshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
                     <attribute name="unmarshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
                     <attribute name="dataType" isParam="true">jms</attribute>
                     <attribute name="socket.check_connection" isParam="true">false</attribute>
                     <attribute name="timeout" isParam="true">0</attribute>
                     <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
                     <attribute name="serverBindPort">4457</attribute>
                     <attribute name="leasePeriod">10000</attribute>
                     <attribute name="clientSocketClass" isParam="true">org.jboss.jms.client.remoting.ClientSocketWrapper</attribute>
                     <attribute name="serverSocketClass">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute>
                     <attribute name="numberOfRetries" isParam="true">1</attribute>
                     <attribute name="numberOfCallRetries" isParam="true">1</attribute>
                     <attribute name="clientMaxPoolSize" isParam="true">50</attribute>
                  </invoker>
                 <handlers>
                    <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler>
                 </handlers>
              </config>
         ]]></attribute>
         </delegate-config>
         <binding port="4457"/>
      </service-config>

   </server>

   <!-- ********************************************************** -->
   <!-- *                          ports-01                      * -->
   <!-- ********************************************************** -->
   <server name="ports-01">

      <!-- EJB3 Remoting Connector ejb3.deployer/META-INF/jboss-service.xml -->

      <service-config name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
        <delegate-config>
           <attribute name="InvokerLocator">socket://${jboss.bind.address}:3973</attribute>
        </delegate-config>
         <binding port="3973"/>
      </service-config>

      <!-- ********************* jboss-service.xml ****************** -->

      <service-config name="jboss:service=Naming"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port" hostName="BindAddress">
            <attribute name="RmiPort">1198</attribute>
         </delegate-config>
         <binding port="1199" host="${jboss.bind.address}"/>
      </service-config>


      <service-config name="jboss:service=WebService"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="9183"/>
      </service-config>


      <service-config name="jboss:service=invoker,type=jrmp"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="RMIObjectPort"/>
         <binding port="4544"/>
      </service-config>


      <service-config name="jboss:service=invoker,type=pooled"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="ServerBindPort"/>
         <binding port="4545"/>
      </service-config>


      <!-- ********************* cluster-service.xml **************** -->

      <service-config name="jboss:service=HAJNDI"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="Port" hostName="BindAddress">
            <attribute name="RmiPort">1201</attribute>
         </delegate-config>
         <binding port="1200" host="${jboss.bind.address}"/>
      </service-config>

      <service-config name="jboss:service=invoker,type=jrmpha"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="RMIObjectPort"/>
         <binding port="4544"/>
      </service-config>

      <service-config name="jboss:service=invoker,type=pooledha"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="ServerBindPort"/>
         <binding port="4548"/>
      </service-config>

      <!-- ********************* iiop-service.xml ****************** -->

      <service-config name="jboss:service=CorbaORB"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="3628"/>
      </service-config>


      <!-- ********************* jmx-rmi-adaptor.sar **************** -->

      <service-config name="jboss.jmx:type=Connector,name=RMI"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="RMIObjectPort"/>
         <binding port="19101"/>
      </service-config>


      <!-- ********************* snmp-adaptor.sar ****************** -->

      <service-config name="jboss.jmx:name=SnmpAgent,service=trapd,type=logger"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="1262"/>
      </service-config>

      <service-config name="jboss.jmx:name=SnmpAgent,service=snmp,type=adaptor"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="1261"/>
      </service-config>


      <!-- ********************* jbossmq-service.xml **************** -->

      <!-- JMS related services -->
      <service-config name="jboss.mq:service=InvocationLayer,type=UIL2"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="ServerBindPort"/>
         <binding port="8193"/>
      </service-config>


      <!-- ********************* jbossmq-httpil.sar **************** -->
      <service-config name="jboss.mq:service=InvocationLayer,type=HTTP"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="URLPort"/>
         <binding port="9180"/>
      </service-config>

      <!-- ********************* hajndi-jms-ds.xml **************** -->

      <!-- The JMS provider loader -->
      <service-config name="jboss.mq:service=JMSProviderLoader,name=HAJNDIJMSProvider"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <!--
              MAKE SURE java.naming.provider.url
              PORT IS SAME AS HA-JNDI ABOVE !!!
         -->
         <delegate-config>
            <attribute name="Properties"><![CDATA[
                java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
                java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
                java.naming.provider.url=${jboss.bind.address:localhost}:1200
                jnp.disableDiscovery=false
                jnp.partitionName=${jboss.partition.name:DefaultPartition}
                jnp.discoveryGroup=${jboss.partition.udpGroup:230.0.0.4}
                jnp.discoveryPort=1102
                jnp.discoveryTTL=16
                jnp.discoveryTimeout=5000
                jnp.maxRetries=1
           ]]>
           </attribute>
        </delegate-config>
        <!-- NOTE: YOU MUST ADD THIS ELEMENT, BUT THE VALUE DOESN'T MATTER
             BE SURE THE CORRECT VALUE IS IN java.naming.provider.url ABOVE -->
        <binding port="1200"/>
      </service-config>

      <!-- **************** http-invoker.sar & httpha-invoker.sar*************** -->
      <!-- EJBInvoker -->
      <service-config name="jboss:service=invoker,type=http"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerServlet</attribute>
        </delegate-config>
         <!--
            MUST BE THE SAME AS
            TOMCAT HTTP CONNECTOR BELOW !!!
             -->
         <binding port="9180"/>
      </service-config>

        <!-- JMXInvoker -->
      <service-config name="jboss:service=invoker,type=http,target=Naming"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerServlet</attribute>
        </delegate-config>
         <!--
            MUST BE THE SAME AS
            TOMCAT HTTP CONNECTOR BELOW !!!
             -->
         <binding port="9180"/>
      </service-config>

        <!-- readonly JMXInvoker -->
      <service-config name="jboss:service=invoker,type=http,target=Naming,readonly=true"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/readonly/JMXInvokerServlet</attribute>
        </delegate-config>
         <!--
            MUST BE THE SAME AS
            TOMCAT HTTP CONNECTOR BELOW !!!
             -->
         <binding port="9180"/>
      </service-config>

    <!-- **************** httpha-invoker.sar*************** -->
      <!-- EJBInvokerHA -->
      <service-config name="jboss:service=invoker,type=httpHA"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerHAServlet</attribute>
        </delegate-config>
         <binding port="9180"/>
      </service-config>

      <!-- JMXInvokerHA -->
      <service-config name="jboss:service=invoker,type=http,target=HAJNDI"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerHAServlet</attribute>
        </delegate-config>
         <binding port="9180"/>
      </service-config>




      <!-- ********************* jboss-ws4ee.sar **************** -->

      <!-- Web Service related services -->
      <service-config name="jboss.ws4ee:service=AxisService"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
        <delegate-config portName="WebServicePort" hostName="WebServiceHost"/>
        <binding port="9180" host="${jboss.bind.address}"/>
      </service-config>

      <!-- ********************* remoting **************** -->

       <!-- *** remoting connector *** -->
       <service-config name="jboss.remoting:service=Connector,transport=socket"
          delegateClass="org.jboss.services.binding.XSLTConfigDelegate">
          <delegate-config>
             <xslt-config configName="Configuration"><![CDATA[
               <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

                  <xsl:output method="xml" />
                  <xsl:param name="port"/>

                  <xsl:template match="/">
                     <xsl:apply-templates/>
                  </xsl:template>

                  <xsl:template match="attribute[@name='serverBindPort']">
                     <attribute type="java.lang.String" name="serverBindPort"><xsl:value-of select='$port'/></attribute>
                  </xsl:template>

                  <xsl:template match="*|@*">
                     <xsl:copy>
                        <xsl:apply-templates select="@*|node()"/>
                     </xsl:copy>
                  </xsl:template>
               </xsl:stylesheet>
          ]]>
          </xslt-config>
          </delegate-config>
          <binding port="5446" />
       </service-config>

      <!-- ********************* hsqldb-ds.xml ********************** -->

      <!-- Hypersonic related services

            Only if using TCP setup (local file setup by default)

      <service-config name="jboss.jca:service=ManagedConnectionFactory,name=DefaultDS"
         delegateClass="org.jboss.services.binding.XSLTConfigDelegate"
      >
         <delegate-config>
         <xslt-config configName="ManagedConnectionFactoryProperties"><![CDATA[
<xsl:stylesheet
      xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

  <xsl:output method="xml" />
  <xsl:param name="host"/>
  <xsl:param name="port"/>

  <xsl:template match="/">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="config-property[@name='ConnectionURL']">
    <config-property type="java.lang.String" name="ConnectionURL">jdbc:hsqldb:hsql://<xsl:value-of select='$host'/>:<xsl:value-of select='$port'/></config-property>
  </xsl:template>

  <xsl:template match="*|@*">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
]]>
         </xslt-config>
         </delegate-config>
         <binding host="localhost" port="1801" />
      </service-config>

      <service-config name="jboss:service=Hypersonic"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
      >
         <delegate-config portName="Port" />
         <binding port="1801" />
      </service-config>

      -->


      <!-- ********************* tomcat ********************** -->

      <service-config name="jboss.web:service=WebServer"
         delegateClass="org.jboss.services.binding.XSLTFileDelegate"
         >
         <delegate-config>
            <xslt-config configName="ConfigFile"><![CDATA[
   <xsl:stylesheet
         xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

     <xsl:output method="xml" />
     <xsl:param name="port"/>

     <xsl:variable name="portAJP" select="$port - 71"/>
     <xsl:variable name="portHttps" select="$port + 363"/>

     <xsl:template match="/">
       <xsl:apply-templates/>
     </xsl:template>

      <xsl:template match = "Connector">
         <Connector>
            <xsl:for-each select="@*">
            <xsl:choose>
               <xsl:when test="(name() = 'port' and . = '9080')">
                  <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute>
               </xsl:when>
               <xsl:when test="(name() = 'port' and . = '8009')">
                  <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute>
               </xsl:when>
               <xsl:when test="(name() = 'redirectPort')">
                  <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute>
               </xsl:when>
               <xsl:when test="(name() = 'port' and . = '8443')">
                  <xsl:attribute name="port"><xsl:value-of select="$portHttps" /></xsl:attribute>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
               </xsl:otherwise>
            </xsl:choose>
            </xsl:for-each>
            <xsl:apply-templates/>
         </Connector>
      </xsl:template>

     <xsl:template match="*|@*">
       <xsl:copy>
         <xsl:apply-templates select="@*|node()"/>
       </xsl:copy>
     </xsl:template>
   </xsl:stylesheet>
   ]]>
            </xslt-config>
         </delegate-config>
         <binding port="9180"/>
      </service-config>

      <!-- ********************* jboss messaging ********************** -->

      <service-config name="jboss.messaging:service=Connector,transport=bisocket"
                      delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config>
            <attribute name="Configuration"><![CDATA[
               <config>
                  <invoker transport="bisocket">
                     <attribute name="marshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
                     <attribute name="unmarshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
                     <attribute name="dataType" isParam="true">jms</attribute>
                     <attribute name="socket.check_connection" isParam="true">false</attribute>
                     <attribute name="timeout" isParam="true">0</attribute>
                     <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
                     <attribute name="serverBindPort">4557</attribute>
                     <attribute name="leasePeriod">10000</attribute>
                     <attribute name="clientSocketClass" isParam="true">org.jboss.jms.client.remoting.ClientSocketWrapper</attribute>
                     <attribute name="serverSocketClass">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute>
                     <attribute name="numberOfRetries" isParam="true">1</attribute>
                     <attribute name="numberOfCallRetries" isParam="true">1</attribute>
                     <attribute name="clientMaxPoolSize" isParam="true">50</attribute>
                  </invoker>
                 <handlers>
                    <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler>
                 </handlers>
              </config>
         ]]></attribute>
         </delegate-config>
         <binding port="4557"/>
      </service-config>

   </server>

   <!-- ********************************************************** -->
   <!-- *                          ports-02                      * -->
   <!-- ********************************************************** -->
   <server name="ports-02">

      <!-- EJB3 Remoting Connector ejb3.deployer/META-INF/jboss-service.xml -->

      <service-config name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
        <delegate-config>
           <attribute name="InvokerLocator">socket://${jboss.bind.address}:4073</attribute>
        </delegate-config>
         <binding port="4073"/>
      </service-config>

      <!-- ********************* jboss-service.xml ****************** -->

      <service-config name="jboss:service=Naming"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port" hostName="BindAddress">
            <attribute name="RmiPort">1298</attribute>
         </delegate-config>
         <binding port="1299" host="${jboss.bind.address}"/>
      </service-config>


      <service-config name="jboss:service=WebService"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="9283"/>
      </service-config>


      <service-config name="jboss:service=invoker,type=jrmp"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="RMIObjectPort"/>
         <binding port="4644"/>
      </service-config>


      <service-config name="jboss:service=invoker,type=pooled"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="ServerBindPort"/>
         <binding port="4645"/>
      </service-config>


      <!-- ********************* cluster-service.xml **************** -->

      <service-config name="jboss:service=HAJNDI"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="Port" hostName="BindAddress">
            <attribute name="RmiPort">1301</attribute>
         </delegate-config>
         <binding port="1300" host="${jboss.bind.address}"/>
      </service-config>

      <service-config name="jboss:service=invoker,type=jrmpha"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="RMIObjectPort"/>
         <binding port="4644"/>
      </service-config>

      <service-config name="jboss:service=invoker,type=pooledha"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="ServerBindPort"/>
         <binding port="4648"/>
      </service-config>

      <!-- ********************* iiop-service.xml ****************** -->

      <service-config name="jboss:service=CorbaORB"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="3728"/>
      </service-config>


      <!-- ********************* jmx-rmi-adaptor.sar **************** -->

      <service-config name="jboss.jmx:type=Connector,name=RMI"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="RMIObjectPort"/>
         <binding port="19201"/>
      </service-config>


      <!-- ********************* snmp-adaptor.sar ****************** -->

      <service-config name="jboss.jmx:name=SnmpAgent,service=trapd,type=logger"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="1362"/>
      </service-config>

      <service-config name="jboss.jmx:name=SnmpAgent,service=snmp,type=adaptor"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="1361"/>
      </service-config>


      <!-- ********************* jbossmq-service.xml **************** -->

      <!-- JMS related services -->
      <service-config name="jboss.mq:service=InvocationLayer,type=UIL2"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="ServerBindPort"/>
         <binding port="8293"/>
      </service-config>


      <!-- ********************* jbossmq-httpil.sar **************** -->
      <service-config name="jboss.mq:service=InvocationLayer,type=HTTP"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="URLPort"/>
         <binding port="8280"/>
      </service-config>

      <!-- ********************* hajndi-jms-ds.xml **************** -->

      <!-- The JMS provider loader -->
      <service-config name="jboss.mq:service=JMSProviderLoader,name=HAJNDIJMSProvider"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <!--
              MAKE SURE java.naming.provider.url
              PORT IS SAME AS HA-JNDI ABOVE !!!
         -->
         <delegate-config>
            <attribute name="Properties"><![CDATA[
                java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
                java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
                java.naming.provider.url=${jboss.bind.address:localhost}:1300
                jnp.disableDiscovery=false
                jnp.partitionName=${jboss.partition.name:DefaultPartition}
                jnp.discoveryGroup=${jboss.partition.udpGroup:230.0.0.4}
                jnp.discoveryPort=1102
                jnp.discoveryTTL=16
                jnp.discoveryTimeout=5000
                jnp.maxRetries=1
           ]]>
           </attribute>
        </delegate-config>
        <!-- NOTE: YOU MUST ADD THIS ELEMENT, BUT THE VALUE DOESN'T MATTER
             BE SURE THE CORRECT VALUE IS IN java.naming.provider.url ABOVE -->
        <binding port="1300"/>
      </service-config>

      <!-- **************** http-invoker.sar & httpha-invoker.sar*************** -->
      <!-- EJBInvoker -->
      <service-config name="jboss:service=invoker,type=http"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerServlet</attribute>
        </delegate-config>
         <!--
            MUST BE THE SAME AS
            TOMCAT HTTP CONNECTOR BELOW !!!
             -->
         <binding port="8280"/>
      </service-config>

        <!-- JMXInvoker -->
      <service-config name="jboss:service=invoker,type=http,target=Naming"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerServlet</attribute>
        </delegate-config>
         <!--
            MUST BE THE SAME AS
            TOMCAT HTTP CONNECTOR BELOW !!!
             -->
         <binding port="8280"/>
      </service-config>

        <!-- readonly JMXInvoker -->
      <service-config name="jboss:service=invoker,type=http,target=Naming,readonly=true"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/readonly/JMXInvokerServlet</attribute>
        </delegate-config>
         <!--
            MUST BE THE SAME AS
            TOMCAT HTTP CONNECTOR BELOW !!!
             -->
         <binding port="8280"/>
      </service-config>

    <!-- **************** httpha-invoker.sar*************** -->
      <!-- EJBInvokerHA -->
      <service-config name="jboss:service=invoker,type=httpHA"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerHAServlet</attribute>
        </delegate-config>
         <binding port="8280"/>
      </service-config>

      <!-- JMXInvokerHA -->
      <service-config name="jboss:service=invoker,type=http,target=HAJNDI"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerHAServlet</attribute>
        </delegate-config>
         <binding port="8280"/>
      </service-config>




      <!-- ********************* jboss-ws4ee.sar **************** -->

      <!-- Web Service related services -->
      <service-config name="jboss.ws4ee:service=AxisService"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
        <delegate-config portName="WebServicePort" hostName="WebServiceHost"/>
        <binding port="8280" host="${jboss.bind.address}"/>
      </service-config>

      <!-- ********************* remoting **************** -->

       <!-- *** remoting connector *** -->
       <service-config name="jboss.remoting:service=Connector,transport=socket"
          delegateClass="org.jboss.services.binding.XSLTConfigDelegate">
          <delegate-config>
             <xslt-config configName="Configuration"><![CDATA[
               <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

                  <xsl:output method="xml" />
                  <xsl:param name="port"/>

                  <xsl:template match="/">
                     <xsl:apply-templates/>
                  </xsl:template>

                  <xsl:template match="attribute[@name='serverBindPort']">
                     <attribute type="java.lang.String" name="serverBindPort"><xsl:value-of select='$port'/></attribute>
                  </xsl:template>

                  <xsl:template match="*|@*">
                     <xsl:copy>
                        <xsl:apply-templates select="@*|node()"/>
                     </xsl:copy>
                  </xsl:template>
               </xsl:stylesheet>
          ]]>
          </xslt-config>
          </delegate-config>
          <binding port="6446" />
       </service-config>


      <!-- ********************* hsqldb-ds.xml ********************** -->

      <!-- Hypersonic related services

            Only if using TCP setup (local file setup by default)

      <service-config name="jboss.jca:service=ManagedConnectionFactory,name=DefaultDS"
         delegateClass="org.jboss.services.binding.XSLTConfigDelegate"
      >
         <delegate-config>
         <xslt-config configName="ManagedConnectionFactoryProperties"><![CDATA[
<xsl:stylesheet
      xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

  <xsl:output method="xml" />
  <xsl:param name="host"/>
  <xsl:param name="port"/>

  <xsl:template match="/">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="config-property[@name='ConnectionURL']">
    <config-property type="java.lang.String" name="ConnectionURL">jdbc:hsqldb:hsql://<xsl:value-of select='$host'/>:<xsl:value-of select='$port'/></config-property>
  </xsl:template>

  <xsl:template match="*|@*">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
]]>
         </xslt-config>
         </delegate-config>
         <binding host="localhost" port="1901" />
      </service-config>

      <service-config name="jboss:service=Hypersonic"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
      >
         <delegate-config portName="Port" />
         <binding port="1901" />
      </service-config>

       -->


      <!-- ********************* tomcat ***************** -->

      <service-config name="jboss.web:service=WebServer"
         delegateClass="org.jboss.services.binding.XSLTFileDelegate"
         >
         <delegate-config>
            <xslt-config configName="ConfigFile"><![CDATA[
   <xsl:stylesheet
         xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

     <xsl:output method="xml" />
     <xsl:param name="port"/>

     <xsl:variable name="portAJP" select="$port - 71"/>
     <xsl:variable name="portHttps" select="$port + 363"/>

     <xsl:template match="/">
       <xsl:apply-templates/>
     </xsl:template>

      <xsl:template match = "Connector">
         <Connector>
            <xsl:for-each select="@*">
            <xsl:choose>
               <xsl:when test="(name() = 'port' and . = '9080')">
                  <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute>
               </xsl:when>
               <xsl:when test="(name() = 'port' and . = '8009')">
                  <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute>
               </xsl:when>
               <xsl:when test="(name() = 'redirectPort')">
                  <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute>
               </xsl:when>
               <xsl:when test="(name() = 'port' and . = '8443')">
                  <xsl:attribute name="port"><xsl:value-of select="$portHttps" /></xsl:attribute>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
               </xsl:otherwise>
            </xsl:choose>
            </xsl:for-each>
            <xsl:apply-templates/>
         </Connector>
      </xsl:template>

     <xsl:template match="*|@*">
       <xsl:copy>
         <xsl:apply-templates select="@*|node()"/>
       </xsl:copy>
     </xsl:template>
   </xsl:stylesheet>
   ]]>
            </xslt-config>
         </delegate-config>
         <binding port="8280"/>
      </service-config>

      <!-- ********************* jboss messaging ********************** -->

      <service-config name="jboss.messaging:service=Connector,transport=bisocket"
                      delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config>
            <attribute name="Configuration"><![CDATA[
               <config>
                  <invoker transport="bisocket">
                     <attribute name="marshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
                     <attribute name="unmarshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
                     <attribute name="dataType" isParam="true">jms</attribute>
                     <attribute name="socket.check_connection" isParam="true">false</attribute>
                     <attribute name="timeout" isParam="true">0</attribute>
                     <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
                     <attribute name="serverBindPort">4657</attribute>
                     <attribute name="leasePeriod">10000</attribute>
                     <attribute name="clientSocketClass" isParam="true">org.jboss.jms.client.remoting.ClientSocketWrapper</attribute>
                     <attribute name="serverSocketClass">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute>
                     <attribute name="numberOfRetries" isParam="true">1</attribute>
                     <attribute name="numberOfCallRetries" isParam="true">1</attribute>
                     <attribute name="clientMaxPoolSize" isParam="true">50</attribute>
                  </invoker>
                 <handlers>
                    <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler>
                 </handlers>
              </config>
         ]]></attribute>
         </delegate-config>
         <binding port="4657"/>
      </service-config>

   </server>

   <!-- ********************************************************** -->
   <!-- *                          ports-03                      * -->
   <!-- ********************************************************** -->
   <server name="ports-03">

      <!-- ********************* jboss-service.xml ****************** -->

      <service-config name="jboss:service=Naming"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port" hostName="BindAddress">
            <attribute name="RmiPort">1398</attribute>
         </delegate-config>
         <binding port="1399" host="${jboss.bind.address}"/>
      </service-config>


      <service-config name="jboss:service=WebService"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="8383"/>
      </service-config>


      <service-config name="jboss:service=invoker,type=jrmp"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="RMIObjectPort"/>
         <binding port="4744"/>
      </service-config>


      <service-config name="jboss:service=invoker,type=pooled"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="ServerBindPort"/>
         <binding port="4745"/>
      </service-config>


      <!-- ********************* cluster-service.xml **************** -->

      <service-config name="jboss:service=HAJNDI"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="Port" hostName="BindAddress">
            <attribute name="RmiPort">1401</attribute>
         </delegate-config>
         <binding port="1400" host="${jboss.bind.address}"/>
      </service-config>

      <service-config name="jboss:service=invoker,type=jrmpha"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="RMIObjectPort"/>
         <binding port="4744"/>
      </service-config>

      <service-config name="jboss:service=invoker,type=pooledha"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="ServerBindPort"/>
         <binding port="4748"/>
      </service-config>

      <!-- ********************* iiop-service.xml ****************** -->

      <service-config name="jboss:service=CorbaORB"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="3828"/>
      </service-config>


      <!-- ********************* jmx-rmi-adaptor.sar **************** -->

      <service-config name="jboss.jmx:type=Connector,name=RMI"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="RMIObjectPort"/>
         <binding port="19301"/>
      </service-config>


      <!-- ********************* snmp-adaptor.sar ****************** -->

      <service-config name="jboss.jmx:name=SnmpAgent,service=trapd,type=logger"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="1462"/>
      </service-config>

      <service-config name="jboss.jmx:name=SnmpAgent,service=snmp,type=adaptor"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="1461"/>
      </service-config>


      <!-- ********************* jbossmq-service.xml **************** -->

      <!-- JMS related services -->
      <service-config name="jboss.mq:service=InvocationLayer,type=UIL2"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="ServerBindPort"/>
         <binding port="8393"/>
      </service-config>


      <!-- ********************* jbossmq-httpil.sar **************** -->
      <service-config name="jboss.mq:service=InvocationLayer,type=HTTP"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="URLPort"/>
         <binding port="8380"/>
      </service-config>

      <!-- ********************* hajndi-jms-ds.xml **************** -->

      <!-- The JMS provider loader -->
      <service-config name="jboss.mq:service=JMSProviderLoader,name=HAJNDIJMSProvider"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <!--
              MAKE SURE java.naming.provider.url
              PORT IS SAME AS HA-JNDI ABOVE !!!
         -->
         <delegate-config>
            <attribute name="Properties"><![CDATA[
                java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
                java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
                java.naming.provider.url=${jboss.bind.address:localhost}:1400
                jnp.disableDiscovery=false
                jnp.partitionName=${jboss.partition.name:DefaultPartition}
                jnp.discoveryGroup=${jboss.partition.udpGroup:230.0.0.4}
                jnp.discoveryPort=1102
                jnp.discoveryTTL=16
                jnp.discoveryTimeout=5000
                jnp.maxRetries=1
           ]]>
           </attribute>
        </delegate-config>
        <!-- NOTE: YOU MUST ADD THIS ELEMENT, BUT THE VALUE DOESN'T MATTER
             BE SURE THE CORRECT VALUE IS IN java.naming.provider.url ABOVE -->
        <binding port="1400"/>
      </service-config>

      <!-- **************** http-invoker.sar & httpha-invoker.sar*************** -->
      <!-- EJBInvoker -->
      <service-config name="jboss:service=invoker,type=http"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerServlet</attribute>
        </delegate-config>
         <!--
            MUST BE THE SAME AS
            TOMCAT HTTP CONNECTOR BELOW !!!
             -->
         <binding port="8380"/>
      </service-config>

        <!-- JMXInvoker -->
      <service-config name="jboss:service=invoker,type=http,target=Naming"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerServlet</attribute>
        </delegate-config>
         <!--
            MUST BE THE SAME AS
            TOMCAT HTTP CONNECTOR BELOW !!!
             -->
         <binding port="8380"/>
      </service-config>

        <!-- readonly JMXInvoker -->
      <service-config name="jboss:service=invoker,type=http,target=Naming,readonly=true"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/readonly/JMXInvokerServlet</attribute>
        </delegate-config>
         <!--
            MUST BE THE SAME AS
            TOMCAT HTTP CONNECTOR BELOW !!!
             -->
         <binding port="8380"/>
      </service-config>

    <!-- **************** httpha-invoker.sar*************** -->
      <!-- EJBInvokerHA -->
      <service-config name="jboss:service=invoker,type=httpHA"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerHAServlet</attribute>
        </delegate-config>
         <binding port="8380"/>
      </service-config>

      <!-- JMXInvokerHA -->
      <service-config name="jboss:service=invoker,type=http,target=HAJNDI"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerHAServlet</attribute>
        </delegate-config>
         <binding port="8380"/>
      </service-config>




      <!-- ********************* jboss-ws4ee.sar **************** -->

      <!-- Web Service related services -->
      <service-config name="jboss.ws4ee:service=AxisService"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
        <delegate-config portName="WebServicePort" hostName="WebServiceHost"/>
        <binding port="8380" host="${jboss.bind.address}"/>
      </service-config>

      <!-- ********************* hsqldb-ds.xml ********************** -->

      <!-- Hypersonic related services

            Only if using TCP setup (local file setup by default)

      <service-config name="jboss.jca:service=ManagedConnectionFactory,name=DefaultDS"
         delegateClass="org.jboss.services.binding.XSLTConfigDelegate"
      >
         <delegate-config>
         <xslt-config configName="ManagedConnectionFactoryProperties"><![CDATA[
<xsl:stylesheet
      xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

  <xsl:output method="xml" />
  <xsl:param name="host"/>
  <xsl:param name="port"/>

  <xsl:template match="/">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="config-property[@name='ConnectionURL']">
    <config-property type="java.lang.String" name="ConnectionURL">jdbc:hsqldb:hsql://<xsl:value-of select='$host'/>:<xsl:value-of select='$port'/></config-property>
  </xsl:template>

  <xsl:template match="*|@*">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
]]>
         </xslt-config>
         </delegate-config>
         <binding host="localhost" port="1901" />
      </service-config>

      <service-config name="jboss:service=Hypersonic"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
      >
         <delegate-config portName="Port" />
         <binding port="1901" />
      </service-config>

       -->


      <!-- ********************* tomcat ********************** -->

      <service-config name="jboss.web:service=WebServer"
         delegateClass="org.jboss.services.binding.XSLTFileDelegate"
         >
         <delegate-config>
            <xslt-config configName="ConfigFile"><![CDATA[
   <xsl:stylesheet
         xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

     <xsl:output method="xml" />
     <xsl:param name="port"/>

     <xsl:variable name="portAJP" select="$port - 71"/>
     <xsl:variable name="portHttps" select="$port + 363"/>

     <xsl:template match="/">
       <xsl:apply-templates/>
     </xsl:template>

      <xsl:template match = "Connector">
         <Connector>
            <xsl:for-each select="@*">
            <xsl:choose>
               <xsl:when test="(name() = 'port' and . = '9080')">
                  <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute>
               </xsl:when>
               <xsl:when test="(name() = 'port' and . = '8009')">
                  <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute>
               </xsl:when>
               <xsl:when test="(name() = 'redirectPort')">
                  <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute>
               </xsl:when>
               <xsl:when test="(name() = 'port' and . = '8443')">
                  <xsl:attribute name="port"><xsl:value-of select="$portHttps" /></xsl:attribute>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
               </xsl:otherwise>
            </xsl:choose>
            </xsl:for-each>
            <xsl:apply-templates/>
         </Connector>
      </xsl:template>

     <xsl:template match="*|@*">
       <xsl:copy>
         <xsl:apply-templates select="@*|node()"/>
       </xsl:copy>
     </xsl:template>
   </xsl:stylesheet>
   ]]>
            </xslt-config>
         </delegate-config>
         <binding port="8380"/>
      </service-config>

      <!-- ********************* jboss messaging ********************** -->

      <service-config name="jboss.messaging:service=Connector,transport=bisocket"
                      delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config>
            <attribute name="Configuration"><![CDATA[
               <config>
                  <invoker transport="bisocket">
                     <attribute name="marshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
                     <attribute name="unmarshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
                     <attribute name="dataType" isParam="true">jms</attribute>
                     <attribute name="socket.check_connection" isParam="true">false</attribute>
                     <attribute name="timeout" isParam="true">0</attribute>
                     <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
                     <attribute name="serverBindPort">4757</attribute>
                     <attribute name="leasePeriod">10000</attribute>
                     <attribute name="clientSocketClass" isParam="true">org.jboss.jms.client.remoting.ClientSocketWrapper</attribute>
                     <attribute name="serverSocketClass">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute>
                     <attribute name="numberOfRetries" isParam="true">1</attribute>
                     <attribute name="numberOfCallRetries" isParam="true">1</attribute>
                     <attribute name="clientMaxPoolSize" isParam="true">50</attribute>
                  </invoker>
                 <handlers>
                    <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler>
                 </handlers>
              </config>
         ]]></attribute>
         </delegate-config>
         <binding port="4757"/>
      </service-config>

   </server>

</service-bindings>

4) Once you have done uncommenting proper tag from jboss-service.xml, modifying/creating sample-binding.xml for each node/server instance of yours, then its time to start them one by one, all the instances (OR whichever you need).


There is one more thing that may cause port conflict while running JBoss multi-instance configuration.


Go to “server.xml” file from your <%JBoss_Home %>/server/<% JBoss Configuration profile %>/deploy/jboss-web.deployer/


(In JBoss 3.2.6, location would be like  <%JBoss_Home %>/server/<% JBoss Configuration profile %>/deploy/ jbossweb-tomcat55.sar/server.xml)

Modify all port-numbers for HTTP, AJP, SSL(i.e. HTTPS) connector port(s) with values from sample-bindings.xml file.


IMP NOTE -
* You cannot have two daemons listening on the same IP address and same port for incoming requests.  This is not a limitation of JBoss or even of Java, this is true of any server including databases, web servers, application servers, etc.

* So either
      1)    You bind each jboss instance to specific/unique IP OR
      2)    Make each instance listen on same IP but different ports. 
              i.e. Ensure each instance is using a distinct port for each service.
              (Which we did with sample-bindings.xml port changes)
(...from official JBoss website)


5) How to start these instances



* Start each instance one-by-one using command with -c argument, and  ServerPeerID value. e.g. run.bat -b 0.0.0.0 -c node2 -Djboss.messaging.ServerPeerID=2 -org.jboss.logging.Log4jService.catchSystemOut=false >out2.log

* For first jboss instance ServerPeerID value is by default 0 (you need not specify it), but while starting next instance(s) you must use -Djboss.messaging.ServerPeerID argument to specify its value, and this value must be unique for each node/instance.

* Consider I want to run/start three instance, first open three different command prompts and use commands like above mentioned one - 
In following example, for all my JBoss instances IP-Address is the same just ports on which the services are listening differ.

With the use of -b 0.0.0.0, (binding argument) I bind all available addresses to this JBoss instance. i.e. 127.0.0.1, localhost, hostname, and NIC's IP-address(es).

1) To start my default instance (this is server configuration folder name)





2) To start node1 instance




3) To start node2 instance




and so on ...


While starting nodes/instances keep some time lag in between to instance startup, so that each one starts fully before starting the next instance, otherwise it might cause conflicts.


In my next two articles I will be explaining, How to run different eclipse workspaces on multi instance JBoss, and How to start these instances as windows service.


Sp, Enjoy the life :-)


As usual, here are links that have helped me a lot,



1) Book - Manning's JBoss in Action (This book has it all, in detail)


2) This is official JBoss Community Link and probable the best to learn on your own-

3) JBoss General How to

4) Setting up multiple instances of JBoss on the same machine, configuring ports

5) JBoss Service Binding Manager

Comments

Popular posts from this blog

How to install / Configure Mantis For Apache-PHP-PostgreSQL combination

Modified ExtJS LOVCombo (List of Values) ux plugin - with select all, deselect all, text filter, bubble up and bubble down of selection

TriggerField with two triggers, TwinTriggerField with tooltips