How do I setup JBoss 5.1.0.GA to run multiple instances?

Does anyone have any experience or advice in setting up multiple JBoss 5.1.x instances on the same machine that has 1 network card?

Here is what I did:

  1. Installed JBoss 5.1.0.GA into c:\myjboss 1.5. I copied the server/default directory to server/ports-01 and server/ports-02 so they have their own config. did I assume correctly?
  2. Ran .\run.bat -c ports-01
  3. Ran .\run.bat -c ports-02

At this point there are 2 instances but the second instance doesn't load correctly because of what is probably a few port conflicts. For example: the http port ends up being 8080 for both instances, which it gets from line #49 in the C:\myjboss\server\all\conf\bindingservice.beans\META-INF\bindings-jboss-beans.xml file. Earlier in the server load it clearly gets the value from line#63 in that same file. I don't know why it gets part of the port config from line #49 and the other part from line#63. Confused.

I also tried: .\run.bat -Djboss.service.binding.set=ports-01 -c ports-01 and it made little difference.

Any ideas on what I am doing wrong?


Solution 1:

I got it working on my own. The answer were these commands:

.\run.bat -Djboss.service.binding.set=ports-01 -c ports-01

.\run.bat -Djboss.service.binding.set=ports-02 -c ports-02

Also, I had to copy the server/default to 2 new directories called server/ports-01 and server/ports-02 ...

Then , in the server\ports-01\conf\bindingservice.beans\META-INF I had to remove references to instances ports-02, ports-03, and "default" from it.

Then , in the server\ports-02\conf\bindingservice.beans\META-INF I had to remove references to instances ports-01, ports-03, and "default" from it.

Then, finally, I deleted the "standard", "web", and "default" directories from the default installation in the server directory.

Then, I ran both servers with the commands above, and out-of-the-box, they work.

Also, here is a batch file to run clustered instead of separate instances:

@echo off

start .\bin\run.bat -c ports-01 -g MyLocal -u 239.255.100.100 -b 127.0.0.1 -Djboss.messaging.ServerPeerID=1 -Djboss.service.binding.set=ports-01

@echo Wait until first server finishes starting and then hit 
@echo any key to start the second server in the cluster...
pause

start .\bin\run.bat -c ports-02 -g MyLocal -u 239.255.100.100 -b 127.0.0.1 -Djboss.messaging.ServerPeerID=2 -Djboss.service.binding.set=ports-02

Solution 2:

You can also configure multiple jboss instances renaming run.bat and creating a new run.bat running -c instance-name . Then, you'll be able to start Jboss as service and calling run.bat properly.