1

This is noob question but still...

My localhost port 8181 is working but when I run my web application via Netbeans IDE, the default port is 8080. How can I change the default port to 8181?

Nilay Vishwakarma
  • 3,105
  • 1
  • 27
  • 48

1 Answers1

1

It looks like NetBeans 8 reads the default port from http-listener-1 in your domain.xml.

To change it, you have to assign a different port to http-listener-2, because this one uses port 8181 by default.

To do that you have different options:

A)

You can open the Glassfish Admin UI via http://localhost:4848.

Navigate to server-config -> Network Config -> Network Listeners -> http-listener-2 and change the port to something like 8282 (8080 is currently in use by http-listener-1).

Now do the same for http-listener-1 and change the port to 8181.

B)

You can also change it manually directly in the domain.xml, shutdown Glassfish before you start.

Open /glassfish_installation/glassfish/domains/domain1/config/domain.xml with a text-editor and search for 8080. There should be something like:

 <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>

Change that to:

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

C)

You can use asadmin:

asadmin set configs.config.server-config.network-config.network-listeners.network-listener.http-listener-2.port=8282

asadmin set configs.config.server-config.network-config.network-listeners.network-listener.http-listener-1.port=8181

(This works for Glassfish v4, for other versions you may have to adjust the "config path".)

The final step of these solutions is to restart Netbeans and you should be done.

See also:

Community
  • 1
  • 1
unwichtich
  • 13,712
  • 4
  • 53
  • 66
  • The problem with this solution is that, I wont be able to run the application on https (currently 8181). http-listener-2 is secure and which is why I need to run the application on it. Changing port value would just swap the two ports but their properties would remain the same. I need to run the application on http-listener-2 by default – Nilay Vishwakarma Jan 16 '15 at 03:49
  • What is the problem with enabling Security on http-listener-1? – unwichtich Jan 16 '15 at 08:37
  • since the same server is used by other applications, I do not think it would be a 'good' method to change the port's settings. Anyway, if there is no possibility I might as well change the setting. Agree? – Nilay Vishwakarma Jan 16 '15 at 09:34
  • I don't see a possibility to tell Netbeans that it should deploy applications on http-listener-2 so I guess you have to change the setting. – unwichtich Jan 16 '15 at 10:03