Tips and Tricks: JBoss Port Configuration Running Multiple Application Instances

September 2007

Situation
You need multiple development environments for your JBoss application, but you only have one development server.

Problem
It is very difficult to get all the TCP port configurations right, due to multiple configuration files.  Not to mention, each configuration file is formatted differently than the next.

Solution
Use JBoss’ port binding service to consolidate all the TCP settings in one easy to maintain file.

Tips and Tricks

First, you’ll need to determine where you want to keep your port configuration file.  A good place for this is {JBOSS_HOME}/conf/port-bindings.xml.  Create the initial port-bindings.xml file by copying {JBOSS_HOME}/docs/examples/binding-manager/sample-bindings.xml to {JBOSS_HOME}/conf/port-bindings.xml.

Now enable the Port Binding MBean in each {JBOSS_HOME}/server/{servername}/conf/jboss-service.xml by uncommenting the ServiceBindingManager MBean and editing to look exactly like:

  1. <mbean code="org.jboss.services.binding.ServiceBindingManager">
  2. <name="jboss.system:service=ServiceBindingManager">
  3. <attribute name="ServerName">${jboss.server.name}</attribute>
  4. <attribute name="StoreURL">${jboss.home.url}/conf/port-bindings.xml</attribute>
  5. <attribute name="StoreFactoryClassName">org.jboss.services.binding.XMLServicesStoreFactory</attribute>
  6. </mbean>

Notice that the “ServerName” attribute is set dynamically to the running {JBOSS_HOME}/server/servername.  This means that you can copy the jboss-service.xml to all your application directories without alteration and they will all point to the correct place in the port-bindings.xml file.

In your newly created conf/port-bindings.xml file, you need to map the different sections of the configuration file to your deployed applications.  There are four server TCP configurations defined in the sample file.  They are identified by the XML tag :

Server Name

HTTP Port

HTTPS Port

RMI Port

ports-default

8080

8443

1098

ports-01

8180

8543

1198

ports-02

8280

8643

1298

ports-03

8380

8743

1398

All you need to do is to change the tag to and the application running from {JBOSS_HOME}/server/myapp/deploy will run on http://localhost:8180 and will not collide with any other JBoss application.

Note also that the ports are just increased by 100 for each section.  To create a fifth configuration, you can copy the section, set the name to what you need, and add 100 to all the ports in that section.  We have successfully configured a single JBoss installation to run 10 development environments without problems.

If you need more information, contact Gary Codeluppi at 937-431-1026 x123 or visit the Ross Group Inc web site at www.rossgroupinc.com.

Comments (0)Add Comment
Write comment
 
 
smaller | bigger
 

busy
search | login