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


Unknown March 29, 2010 at 12:04 PM  

but what do you mean with:

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


Luiz Gustavo

Unknown March 29, 2010 at 12:13 PM  

Oh, I realized it!
I can't use these comands at the same time, in the same domain creation command.

That's ok!

Nice tip!


Unknown March 29, 2010 at 9:17 PM  

Ya, You got the point.


Anonymous February 29, 2012 at 2:41 AM  

works a treat! thanks for that!

vasu June 7, 2012 at 2:29 AM  

if two domain share same database and i login on first domain how to post username and password to other domain no need to login again on second domain+core php

Victor August 22, 2012 at 2:22 PM  


Anonymous August 20, 2013 at 9:30 PM  

We posted an article this week about how to do this using Jelastic - Running Multiple Domains with Glassfish

Keen to hear your feedback :)

Total Pageviews


Twitter Updates
    follow me on Twitter