A common problem that I encounter is the need to configure JBoss to work on a different set of ports. If for some reason the environment is already using port 1099 and 1100, 8080 is not available, etc, then I have to change the ports JBoss is running on. The hard way of solving this problem is by changing all the ports manually. That means editing all the JBoss service configurations and changing the ports there. This process is almost impossible considering how many configuration files and ports are involved. Not only that, your configurations need to match between files. It can really be a nightmare.
Thankfully there is another solution. JBoss has a Binding Manager service. You can configure this service to bind ports defined in a configuration file. JBoss also provides a sample configuration file with 4 sets of ports. In order to use this service you need to do the following (JBOSS_HOME represents the directory where JBoss is installed and SERVER_NAME represents the server instance you are working with):
1) Find sample-bindings.xml . It is usually located at /JBOSS_HOME/docs/examples/binding-manager/ . If you can't find it there, download JBoss and it will be in that zip file.
2) Copy that file to /JBOSS_HOME/server/SERVER_NAME/conf/ . I like to rename the file to bindings.xml, but that is up to you. The rest of the tutorial assumes you did not rename the file.
2) Enable the binding manager service. Open /JBOSS_HOME/server/SERVER_NAME/conf/jboss-service.xml. In that file uncomment the following section and make the change indicated in red:
<mbean code="org.jboss.services.binding.ServiceBindingManager"
name="jboss.system:service=ServiceBindingManager">
<attribute name="ServerName">ports-01</attribute>
<attribute name="StoreURL">${jboss.server.home.dir}/conf/sample-bindings.xml</attribute>
<attribute name="StoreFactoryClassName">
org.jboss.services.binding.XMLServicesStoreFactory
</attribute>
</mbean>
Note that we changed StoreURL to point to the file you copied over. The other important attribute here is ServerName. ServerName specifies the set of ports to use from sample-bindings.xml. You can find the different servers names in sample-bindings.xml by searching for:
<server name
Bellow each of the server name tags you will find the port definitions. The options for the ServerName attribute with the default content of sample-bindings.xml are:
- ports-default
- ports-01
- ports-02
- ports-03
Look into sample-bindings to see to what ports each of those configurations binds to.
3) Save jboss-service.xml and restart JBoss. Now JBoss should be binding to the set of ports defined by ports-01.
An extra feature of this mechanism is in the fact that you can easily create your own set of custom ports to run JBoss on. Just copy everything from <server name="ports-01"> to </server> and attach it to sample-bindings, change the name attribute and you are ready to change that configuration to your heart's content. Then simply specify the name of that configuration in the ServerName attribute of the binding manager service (in jboss-service.xml).
It also resolves the issue of multiple instances of JBOSS
Posted by: Prasanth | July 09, 2008 at 12:16 AM
Thank you for posting this. It was exactly what I was looking for when trying to run JBoss AS and portal server on the same host for the first time. Cheers
Posted by: Tommy | October 01, 2008 at 01:45 AM
Thank you very much for helpful information.
Posted by: Jukka | February 18, 2009 at 05:09 AM
What about shutting down the second instance?
I've tried shutdown.sh specifying -Djboss.service.binding.set as a parameter, but it still shuts down the first instance.
Posted by: www.facebook.com/profile.php?id=567062661 | September 17, 2009 at 02:14 PM
I really like this blog, you are very good making them. I say that the issue discussed in this blog is quite interesting and of high quality.
Posted by: viagra online | February 23, 2010 at 09:15 AM