How to Run Multiple Domain of GlassFish Simultaneously (Use --portbase option)

In many cases you may need to run multiple domains of GlassFish simultaneously. Few days ago I was in a situation to run 3 domains concurrently. At first I was creating domain with only --adminport option to assign different admin port to different domains. But when I try to run those domains simultaneously I was getting port conflict error. Then I found that there are many other ports in GlassFish for other purposes. Default ports for GlassFish are

4848 Admin port
8080 HTTP Instance port
7676 JMS port
3700 IIOP port
8181 HTTP_SSL port
3820 IIOP_SSL port
8686 JMX_ADMIN port

So to avoid port conflict you have to assign different port numbers in different domains for each purpose. The easy way of doing this is using portbase option in create-domain command. You just have to set a base port number and the values for the ports are calculated as follows

Admin port: portbase + 48
HTTP listener port: portbase + 80
IIOP listener port: portbase + 37
JMX port: portbase + 86

Here is an example of create-domain command with portbase option

asadmin create-domain --user admin --portbase 2000 --savemasterpassword=true domain2

-> Adminport should be between 1 and 65535. So choose a portbase value such that the resulting port number doesn't exceed 65535

->The --portbase option can't be used with the --adminport or the --instanceport option

Total Pageviews


Twitter Updates
    follow me on Twitter