How to Fix NetBeans GlassFish Errors — Server Not Starting
In this tutorial, you'll learn about How to Fix NetBeans GlassFish Errors. We cover key concepts, practical examples, and best practices.
The Problem
GlassFish fails to start from NetBeans:
GlassFish Server: start-domain failed.
or:
Port 4848 is already in use.
Quick Fix
Step 1: Check for port conflicts
sudo lsof -i :4848 # Admin port
sudo lsof -i :8080 # HTTP port
sudo lsof -i :8181 # HTTPS port
If ports are in use, change them in GlassFish:
asadmin set configs.config.server-config.network-config.network-listeners.network-listener.admin-listener.port=4949
Step 2: Register GlassFish with NetBeans
Services > Servers > Add Server > GlassFish Server
Point to the GlassFish installation directory.
Step 3: Create a new domain
asadmin create-domain --portbase 5000 mydomain
Then register the new domain in NetBeans.
Step 4: Fix deployment failures
Clean the build and redeploy:
Right-click project > Clean and Build
Services > Servers > GlassFish > Start
Right-click project > Deploy
Step 5: Increase GlassFish memory
asadmin create-jvm-options -Xmx2048m
Prevention
- Stop GlassFish from NetBeans before shutting down the IDE.
- Use unique port bases for multiple GlassFish instances.
- Monitor GlassFish logs in
glassfish/domains/domain1/logs/.
Common Mistakes with glassfish
- Forgetting
deriving (Show, Eq)on custom data types needed for debugging - Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
- Using
headandtailinstead of pattern matching, causing runtime errors on empty lists
These mistakes appear frequently in real-world NETBEANS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro