I would leave 4.2.2 as is and change the ports on 5.0. To do that, look at the server/xxx/conf/bootstrap/bindings.xml file. All of the ports are configured from this file in 5.0. In fact, you could start 5.0 like this:
and it will run with port numbers increased by 100 (example: using port 8180 instead of 8080)
If you want to change the ports on 4.2.x, see the file docs/examples/binding-manager/sample-bindings.xml, which provides a similar mechanism.
When I add -Djboss.service.binding.set=Ports01Bindings I get this error:
12:48:11,119 ERROR [AbstractKernelController] Error installing to Instantiated:
org.jboss.services.binding.NoSuchBindingException: No binding null found for ser
vice jboss.messaging:service=Connector,transport=bisocket in set Ports01Bindings
Is there something else I need to do?
I've gotten JBoss 5 to run at the same time as JBoss 4 by changing all JBoss 5 port settings in bootstrap/bindings.xml to start with a 9, but your approach is cleaner.
I also changed two port settings in deploy/jbossweb.sar/server.xml, but maybe that isn't necessary.
Changing the ports in server.xml is not necessary - the bindings.xml file includes those ports. But note that the settings in server.xml take precedent if you change them due to the way that the port numbers in binding.xml are applied to server.xml.
And I gave you the wrong port binding name, it should be (sorry):
The last one works.
I asked the same question on stackoverflow.com and got two different, creative answers so I'm going to cross-reference the two threads:
The ability to specify port numbers or an entire set of port bindings with a JVM -D argument will make it easy to do from Ant too.