Running multiple instances of JBoss on the same server

Sometimes it is useful to run more than one instance of JBoss on the same server. Other instances can be set up for development, testing or for quality assurance, etc.

ConfiguringMultipleJBossInstancesOnOneMachine on the JBoss wiki has the basic info but does not seem to be up to date for the newer servers (4.2.x+).

Before setting up another instance, other outside resources may also have to be 'cloned' if it is possible that they may conflict, such as setting up another instance of a database with a separate connection url and matching datasource for JBoss.

The basic steps are as follows:

1) Add port-bindings.xml file for binding service port definitions. This file has the same content as jboss sample-bindings.xml available from the wiki.

Rename to "port-bindings.xml" and save to $JBOSS_HOME/server directory.

2) The binding service manager needs to be enabled in conf/jboss-service.xml for instances that are not using the default ports.

Remove the comments to enable the "ServiceBindingManager" mbean and modify the content as below:

"ServerName" attribute should reference a port configuration in port-bindings.xml and "StoreURL" should point to the port-bindings.xml file

the next few changes are not mentioned in jboss wiki documentation

3) Under "Socket transport Connector", in the "Configuration" section, serverBindPort must be changed to another value or it will conflict with the default (4446).

4) And in
/deploy/ejb3.deployer/META-INF/jboss-service.xml,
for the remoting.transport.Connector mbean, port 3873 must be changed to another value or it will conflict with the default.

5) Also, any startup scripts in $JBOSS_HOME/bin may have to be cloned with different debug ports if remote debugging is enabled.

In summary the directory structure for setting up two other instances would be something like the below with added port-bindings.xml and modifications in the filenames in bold.



$JBOSS_HOME/server/port-bindings.xml
$JBOSS_HOME/server/default
$JBOSS_HOME/server/node1
$JBOSS_HOME/server/node1/conf/jboss-service.xml
$JBOSS_HOME/server/node1/deploy/ejb3.deployer/META-INF/jboss-service.xml
$JBOSS_HOME/server/node2
$JBOSS_HOME/server/node2/conf/jboss-service.xml
$JBOSS_HOME/server/node2/deploy/ejb3.deployer/META-INF/jboss-service.xml

Separate instances are run with "run -c node1" etc. and applications accessed with urls like:

http://localhost:8080/myapp/

http://localhost:8180/myapp/

http://localhost:8280/myapp/

10 Comments

10 Responses to “Running multiple instances of JBoss on the same server”


  1. 1 Nelik

    thanks!!! :)

    it worked perfectly…I was puzzled on how to run multiple instances of JBoss and the wiki that you mentioned doesn’t work so good…

    thanks again, Nelik

  2. 2 Billigflüge

    Very well then! Now it runs perfectly (6 instances on one single server) and I want to let it run simultaneously on two more servers. Do you think there could be any complications? Hmm, I´ll give it a try and report any extraordinary incidents. Thank you so far!

  3. 3 V Vek

    I was successful in setting up 2 instances. Then i wanted to run them as windows service. I set it up fine. BUT, I can run just one of them as a service. When i try to run the other, it pops up the message saying:- “The JBoss service on Local computer started and then stopped. Some services stop automatically if they have no work to do….”. Any idea what I am doing wrong?

    Actually, I can run one as a service and the other in the command prompt. That works fine too. But, to run both as service, fails. Please help!

    Thanks,
    -V

  4. 4 V Vek

    actually, i figured it out.

    1. I created two separate ‘.log’ files.
    2. I created two separate ‘.lock’ files.
    3. Made the new ’service… .bat’ file to point to these.

  5. 5 Rajeev

    Thanks a lot for such notes…
    i was trying to create multiple instance of jboss from last long time..
    i hope it ll help for me

    Thanks Again
    Rajeev

  6. 6 Raju

    I followed these steps i getting the following exception while running my second instance

    “java.rmi.server.ExportException: Port already in use: 0; nested exception”

    can any one help me my mail id is rajumaddy@gmail.com

  7. 7 Calvin

    This whole time I had created a separate JBoss directory structure. I had made the changes but was getting NameAlreadyBoundExceptions. So, I need to use just one instance(directory structure) of JBoss but start up more than one node, correct? Like I want a DEV instance and a QA instance. I will give that a try.

    Thanks,

    Calvin

  8. 8 Calvin

    Excellent! I have it working. Now how do I shutdown just one node? I haven’t been able to figure that out.

  9. 9 ManiKanta

    Nice post :)

    I want to add some thing to this….

    If you’ve changed the Tomcat port (from default 8080) to some other port, say 80, then you need to give the new node a new value.

    File: JBOSS_HOME/server/NEW_NODE/deploy/jboss-web.deployer/server.xml

    and change the value of the port in the config…

    Ex:

    Thanks,
    ManiKanta

  10. 10 rina

    hi experts,

    i couldn’t find this file

    step 3
    Under “Socket transport Connector”, in the “Configuration” section, serverBindPort must be changed to another value or it will conflict with the default (4446).

    can anyone guide me here

    thanks

Leave a Reply