If you are using GlassFish server in NetBeans you can sometimes get an error saying that there is a port conflict and you need to change port of GlassFish web server.
This can happen when you have another web server running on the same port. The default port for GlassFish is 8080.
So, for an example you set your Apache server running on port 8080 you will get a port conflict error.
This conflict error may appear for any other application running on the same port as GlassFish.
To avoid conflicts, we’ll show you how to change default port for GlassFish.
Change Port of GlassFish Web Server
1. Find location of GlassFish server
If you installed GlassFish with NetBeans follow this steps to find installation location:
- Open NetBeans and go to Window -> Services
- Expand Servers from the Services list on the left
- Right click on GlassFish and select Properties
- Look for Installation Location option, that’s where you can find GlassFish installation
2. Editing GlassFish configuration
Go to location where GlassFish installation is located:
You need to edit domain.xml file:
Find this line:
<network-listener port="8080" protocol="http-listener-1" transport="tcp" name="http-listener-1" thread-pool="http-thread-pool"></network-listener>
And replace 8080 with a port number that you are not using.
Save changes and exit file.
3. Adding new server to NetBeans
You need to remove GlassFish server from NetBeans and add it again to apply changes you made before.
Follow procedure for finding servers that we used in the beginning.
Select GlassFish server from the list and click on Remove Server option.
Now, click on Add Server to add a new server with new configuration.
Select GlassFish, then hit Next.
And then select installation location of GlassFish, hit Next.
Accept default settings and click Finish.
You have successfully added a GlassFish web server with different port number.
Now you should have no problems running it on your system with applications that caused conflicts before.