Resolving GlassFish Startup Error in NetBeans: In-Depth Analysis and Solutions for Port Occupation Issues

Dec 02, 2025 · Programming · 8 views · 7.8

Keywords: GlassFish | NetBeans | Port Occupation

Abstract: This article provides a comprehensive analysis of the "HTTP or HTTPS listener port is occupied" error when starting GlassFish 4.1 in NetBeans 8.0.1. By examining the root causes, it offers multiple solutions, including identifying and terminating processes occupying ports, disabling Derby server auto-start, and modifying GlassFish listener ports. Drawing from the best answer in the Q&A data, the article explains the nature of port conflicts in detail and provides step-by-step guidance to help developers effectively resolve this common issue.

Problem Background and Error Analysis

When starting the GlassFish 4.1 server in the NetBeans 8.0.1 integrated development environment on Windows 7, users often encounter the error message: "Could not start GlassFish Server 4.1: HTTP or HTTPS listener port is occupied while server is not running." This error indicates that GlassFish cannot start its HTTP or HTTPS listener on the specified port (default 8080 or 443) because the port is already in use by another process.

The phrase "while server is not running" in the error message suggests that the GlassFish server itself is not yet running, but the port is occupied, typically due to other applications in the system (such as Tomcat, VMware services, or database processes) using the same port. Users executing the command netstat -ano | find "1527" may find port 1527 occupied by the Java Derby database, but this is not the root cause, as Derby is a separate process, and GlassFish might start Derby simultaneously, creating a false impression of port conflict.

Core Solution: Identifying and Resolving Port Occupation

Based on the best answer from the Q&A data (Answer 2), the key to resolving this issue lies in determining the actual process occupying port 8080 or 443 and taking appropriate actions. The following steps provide a systematic approach:

  1. Check Port Occupation: Open Command Prompt and execute the command netstat -aon | find ":8080" | find "LISTENING". This command lists all processes listening on port 8080 along with their PIDs (Process Identifiers). For example, the output might show: TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 1464, where 1464 is the PID.
  2. Terminate the Occupying Process: Open Task Manager, switch to the "Details" tab, and locate the process corresponding to the PID. Right-click the process and select "End task" to free the port. Common applications that occupy ports include Tomcat servers, VMware services (as mentioned in Answer 6), or other web server instances.
  3. Verify GlassFish Startup: After terminating the occupying process, attempt to start GlassFish in NetBeans again. If the error disappears, the issue is resolved; otherwise, further checks on other ports (e.g., 443) or modifications to GlassFish configuration may be necessary.

Supplementary Solution: Disabling Derby Server Auto-Start

If port occupation is not caused by external applications but by GlassFish itself starting the Derby database, disabling Derby's auto-start feature can help:

  1. Ensure the Derby server is shut down. If NetBeans is closed but Derby is still running, terminate all Java processes via Task Manager.
  2. In the NetBeans "Services" tab, right-click the GlassFish instance and select "Properties."
  3. In the properties dialog, find options related to the Derby server and uncheck "Auto-start Derby on startup" or similar settings (the exact name may vary by NetBeans version).
  4. Save the settings and restart GlassFish. This method avoids port conflicts between Derby and GlassFish while maintaining database functionality.

Advanced Configuration: Modifying GlassFish Listener Ports

If the above methods are ineffective or users wish to permanently avoid port conflicts, modifying GlassFish's default listener ports (as described in Answers 3 and 4) is an option:

  1. Locate the configuration file domain.xml in the GlassFish installation directory, typically at GlassFish_Server\glassfish\domains\domain1\config\domain.xml.
  2. Open domain.xml with a text editor and search for the line containing <network-listener port="8080". This line defines the port settings for the HTTP listener.
  3. Change the port number from 8080 to another unused port (e.g., 9090), for example: <network-listener port="9090" protocol="http-listener-1" transport="tcp" name="http-listener-1" thread-pool="http-thread-pool"></network-listener>.
  4. Save the file and restart GlassFish. After modification, GlassFish will run on the new port, avoiding conflicts with existing applications. This method is suitable for scenarios requiring multiple server instances to run simultaneously.

Summary and Best Practices

The key to resolving GlassFish startup errors is accurately diagnosing the source of port occupation. Prioritize using the netstat command and Task Manager to identify and terminate occupying processes, as this is the most direct and effective solution. If the issue is related to the Derby database, disabling its auto-start simplifies configuration. For complex environments or long-term solutions, modifying GlassFish port settings offers flexibility. Developers should regularly check system port usage to prevent similar conflicts and ensure the stability of their development environment.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.