Running multiple instances of Jboss on one server.

jboss ports

To run multiple Jboss instances on the one server is pretty easy – but remember that if you’re running something like ATG commerce you’re going to need a few Gb of memory to run just the one JBoss instance let alone multiples. So you may want seriously consider keeping separate VM’s for each server in your production environment depending on your application requirements e.g for heavyweight commerce keep them all as separate as possible. But for quickly building a development environment this is the way to go.

Anyway, the main thing to worry about with JBoss is the network ports setting as each instance needs it’s own port range, once you’ve done this then it’s all down to your application as to which port set it needs to use. So here’s how to set multiple instances and their respective ports. You’ll see that most if not all config for JBoss is done with XML files.

First we need to create an XML file to store our port bindings, thankfully we can use a sample one which you’ll find in: jboss\docs\examples\binding-manager\sample-bindings.xml and we can create a new directory to store this, something like jboss\bindings\binding.xml

You can see below a section of the code which sets up a ports definition for our server. At most I have done 4 configurations and actively run them all at once on a machine with 3Gb memory and it worked fine for my development requirements. Also I would recommend that you only use 1 bindings file however you can create and use multiple XML’s. Also you will see that we’re using ports 8180 instead of the typical 8080, this potentially leaves you 8080 free for another server giving you 5 in total – or it leaves the ports free if you need to map in an additional server on 8080, like FatWire. Depends on your architecture really, just remember 8080 is the default port setting of JBoss.



   
   
   
   

      

      
        
           socket://${jboss.bind.address}:3973
        
         
       

      

      
         
            1198 
         
          
      

      
         
          
      

      
         
          
      

      
         
          
      

      

      
         
            1201 
         
          
      

      
         
          
      

      
         
          
      
      
      

      
         
          
            

      

      
         
          
      

      

      
         
          
      

      
         
          
      

      

      
      
         
          
      

      
      
         
          
      
      
      
      
      
      
         
         
            
                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
           ]]>
           
        
        
         
      

      
      
      
         
            :${port}/invoker/EJBInvokerServlet
        
         
          
      

        
      
         
            :${port}/invoker/JMXInvokerServlet
        
         
          
      

        
      
         
            :${port}/invoker/readonly/JMXInvokerServlet
        
         
          
      

    
      
      
         
            :${port}/invoker/EJBInvokerHAServlet
        
          
      

      
      
         
            :${port}/invoker/JMXInvokerHAServlet
        
          
      

      

      
      
        
         
      

      

      
      

      
         
          
      

      -->

      

      
         
            

     
     

     
     

     
       
     

      
         
            
            
               
                  
               
               
                  
               
               
                  
               
               
                  
               
               
                  
               
            
            
            
         
      

     
       
         
       
     
   
   ]]>
            
         
          
      

      
      
       
          
            socket://${jboss.bind.address}:4557/?dataType=jms&serializationtype=jms&timeout=0&leasePeriod=20000&socket.check_connection=false&marshaller=org.jboss.jms.server.remoting.JMSWireFormat&unmarshaller=org.jboss.jms.server.remoting.JMSWireFormat 
          
          
      
      
   

The ports can be incremented by 100 for each port in a new port setting, so for instance 8180 can be changed to 8280 to give you a new range. Just leave alone the section headed with:

You should be able to see the differences in the example bindings file between ports-01 and ports-02 setups and I’ve also commented each port change with so you can see which ports to change.

With that file done, next go to your JBoss install directory and then look for your server, if you’re using the default then it will be called… default. You can now duplicate this server if you need to and you’ll be able to run both at the same time with this tutorial. In here we look in the conf directory for a file called jboss-service.xml. The path to this looks something like this: \jboss\server\[SERVER NAME]\conf\jboss-service.xml

So open this file up and look in here for the following section:

   
     [SERVER NAME]
     ${jboss.home.url}/binding/binding.xml
     
       org.jboss.services.binding.XMLServicesStoreFactory
     
   

We then un-comment this section, e.g. remove the ‘–>’. Then we alter the ServerName attribute to match your server’s name and the StoreURL attribute to point to your new bindings file. Repeat this step for each of your servers. The servers name you enter is used to look up the ports configuration in the binding.xml, so if you left it as the default ports-01 then this will be the server name you need to enter.

And that’s pretty much it, if you have port conflict errors onyour startup then look in these files and also check that your application is set to use the particular ports, for instance using ATG we set the dynamo server to use RMI port xxxxx etc… which maps into your JBoss ports config. One other thing – you will always be able to see the ports being used in your JBoss logs if you need to debug.

One Comment

You must be logged in to post a comment.