Belial

Personal Blog

The Best Way to Change Glassfish Ports

So here’s the best solution that works independently of the operative system. Go directly to the configure file located on:

<GLASSFISH_PATH>\glassfish\domains\domain1\config\domain.xml

<GLASSFISH_PATH> is where you installed glassfish and domain1 is the default server name, so it can be different or have more than one, in that case select the server that you want to change their ports.

In my case it was: C:\Program Files\glassfish-3.1.2\glassfish\domains\domain1\config\domain.xml

And look for the network binds like the following:

<network-listeners>
<network-listener port="8080? protocol="http-listener-1? transport="tcp" name="http-listener-1? thread-pool="http-thread-pool"></network-listener>
<network-listener port="8181? protocol="http-listener-2? transport="tcp" name="http-listener-2? thread-pool="http-thread-pool"></network-listener>
<network-listener port="4848? protocol="admin-listener" transport="tcp" name="admin-listener" thread-pool="admin-thread-pool"></network-listener>
</network-listeners>

Then simply change them however you want, in my case I just changed the default listener on 8080 to 8082

<network-listeners>
<network-listener port="8082? protocol="http-listener-1? transport="tcp" name="http-listener-1? thread-pool="http-thread-pool"></network-listener>
<network-listener port="8181? protocol="http-listener-2? transport="tcp" name="http-listener-2? thread-pool="http-thread-pool"></network-listener>
<network-listener port="4848? protocol="admin-listener" transport="tcp" name="admin-listener" thread-pool="admin-thread-pool"></network-listener>
</network-listeners>

As we are changing the config file directly there is no need for commands that are specific to the OS you are using, as most solutions I saw out there were for linux and not as straight forward as this one. Feel free to comment or suggest other simple ways of doing this.

Comments