tags:

views:

3032

answers:

5

I thought this would be a JBoss FAQ, but I can't find it.

I'd like to run JBoss 4 and JBoss 5 at the same time. I manually changed all the ports on the JBoss 5 server/default instance by changing the port's leading digit to a 9, and it seems to work. I can start JBoss 4 and JBoss 5 with no port conflicts.

One of my colleagues said that he thought he had heard that there was a way to "rebase" JBoss 5 to move all the port numbers by a specified amount. That would be a cleaner solution than manually editing the port settings.

Is there a simple way to change the port settings in JBoss 5 so it can run simultaneously with JBoss 4?

+1  A: 

There may be a canonical way to do this, but at work, we did this by inserting a replacement marker within the configuration files, which was scripted. You can probably find a list online of all the ports that you have to change.

Once you do this, it's not too much trouble to set port non-overlapping port windows as you suggest.

Here's an example of the start command we were using (which could be further improved):

run.sh -c <service name> -DJPATH=/usr/local/bin:/usr/bin:/bin:/usr/local/jre1.6.0_03/bin/ -Djboss.bind.address=192.168.110.21 \
-Djboss.port.connector=37079 -Djboss.port.classloader=37080 -Djboss.port.naming=37081 -Djboss.port.namingrmi=37082 -Djboss.port.jmxrmi=37083 \
-Djboss.port.pooled=37084 -Djboss.port.jndinaming=37085 -Djboss.port.jndirmi=37086 -Djboss.port.jms=37087 -Djboss.port.ajp=37078
Dana the Sane
+2  A: 

I don't know of the "rebase" option, but one simple approach is to set up an IP alias and specify the -b option of run.sh to bind to that aliased interface. This is much easier than changing all the ports. The ports can stay the same as long as each JBoss instance is bound to its own address. For example,

$ sudo ip addr add dev lo local 127.0.0.100/24
$ run.sh -b 127.0.0.1
$ run.sh -b 127.0.0.100
$ wget http://127.0.0.1:8080
$ wget http://127.0.0.100:8080

Voila! Two JBoss instances on one host.

jcrossley3
+6  A: 

Two good answers. The IP alias is clever.

I also asked this question on the JBoss forums and it turns out that there are alternate port bindings that you can invoke (the "rebase" option). Start JBoss like this:

run -Djboss.service.binding.set=ports-01

Here's the link to the thread on the JBoss forums (cross-referenced to this thread):

http://www.jboss.org/index.html?module=bb&amp;op=viewtopic&amp;p=4213775#4213775
Dean Schulze
A: 

That's a bit of undertaking an old topic, but I've been asking asking myself the same question recently when migrating a Jboss AS 4 to 5 on our DMZ. Since I could not find any recent post about this, I thought I'd add my 2 cents in here. From the first answer I wrote those 2 sh scripts to have both Jboss4 and 5 running and logging in separate files :

start-jboss4.sh :

#!/bin/sh
nohup /etc/jboss-4.2.3.GA/bin/run.sh -b 10.0.0.51 > jboss4.log &

start-jboss5.sh :

#!/bin/sh
nohup /etc/jboss-5.1.0.GA/bin/run.sh -Djboss.service.binding.set=ports-01 -b 10.0.0.51 >> jboss5.log &

But more importantly with this solution, I ended up asking myself how to stop one of these instances without droping the other one. And this is where the 2 next scripts come to.

stop-jboss4.sh :

#!/bin/sh
/etc/jboss-4.2.3.GA/bin/shutdown.sh -S -s jnp://10.0.0.51

stop-jboss5.sh :

#!/bin/sh
/etc/jboss-5.1.0.GA/bin/shutdown.sh -S -s jnp://10.0.0.51:1199

Note that the first stop script uses JBoss' the default JNDI port. But with the uprated ports the second start script brings, the second stop script uses 1199 (default + 100) as the JNDI port to use when sending the shutdown command.

Hope this helps someone.

jpramondon
A: 

Note that the jboss.service.binding.set property is only used by JBoss 5. So, if you want JBoss 4 on a different port profile you need to modify ${JBOSS_HOME}/server/default/conf/jboss-service.xml.

Look for the element referencing ServiceBindingManager and change the ServerName attribute.

<mbean code="org.jboss.services.binding.ServiceBindingManager"
  name="jboss.system:service=ServiceBindingManager">
  <attribute name="ServerName">ports-01</attribute>
  <attribute name="StoreURL">${jboss.home.url}/docs/examples/binding-manager/sample-bindings.xml</attribute>
  <attribute name="StoreFactoryClassName">
    org.jboss.services.binding.XMLServicesStoreFactory
  </attribute>
</mbean>

The port values used by JBoss 4 are read from ${JBOSS_HOME}/docs/examples/binding-manager/sample-bindings.xml. The default port profile names are as follows:

  • ports-default
  • ports-01
  • ports-02
  • ports-03
phatblat