This tutorial explains about following things
- How to set Tomcat in Netbeans IDE
- How to start a tomcat server in Netbeans
- Fix for tomcat errors in Netbeans
How to set Tomcat in Netbeans
This setup requires downloading the latest Tomcat server from here
It downloads a zip file and extracts it to the
B:\apache-tomcat-9.0.35
folderNext, Open Netbeans Editor
select the
Services
tab, Service is located in the left side navigation with multiple tabsProjects
,Files
, andServices
.The services tab shows you a tree of options.
Select
Servers
, Right click on it, and selectAdd Server
only optionIt opens the
Add Server Instance
window, Select theApache Tomcat or TomEE
optionClick Next, It asks for the below details
- Server Location:
B:\apache-tomcat-9.0.35
is CATALIN_HOME of a tomcat directory - Enter credentials, which are used to log in to the tomcat instance to manage deployments and configuration from GUI.
- username: Tomcat
- password: tomcat
- Click Finish to save the settings
- Server Location:
Tomcat server profile is created and added to Netbeans IDE.
You can start the server from
services
+Servers
.
How to start and run the Tomcat server in Netbeans
To start the tomcat server in Netbeans, Please follow the below steps
Next, Open Netbeans Editor
select the
Services
tabClick on the
Servers
optionUnder Servers, Select the
Apache Tomcat or TomEE
option and right-click on itIt shows a context menu with all options
Start
: Starts the tomcat server at listening default port 8080Stop
: Stops the serverRestart
: stop and start the serverRefresh
: Hot reload option to reload changes- `Start in Debug mode: Start the server in debug mode for breakpoint execution
Start in Profile mode
: Start the server in profile mode to fine-tune the application performanceRemove
: Remove the tomcat profile from theServers
optionRename
: Rename the profile with a new nameView Server Logs
: Server logsView Server Output
: server output console logsProperties
: Settings for tomcat
Once Tomcat is started, You can access
localhost:8080
to access Tomcat GUI
Tomcat Netbeans errors
After following the above steps, It shows Tomcat failed to start the server message.
Fix for tomcat failure errors in Netbeans.
Disable proxy settings
- Go to
tools
+Options
+ selectGeneral
tab - Check the
Proxy Settings
checkbox value toNo Proxy
- Save changes
- Go to
Check the 8080 port used by other processes/service
Tomcat’s default port is 8080, Please make sure that no other process is using this port.
you can still change the port by updating server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
```
port="8080" for HTTP port
redirectPort="8443" for HTTPS port
You can change these values to a new port for the HTTP port.
- Check the use and role mapping in tomcat-users.xml
Sometimes, Even though Tomcat started, you are unable to access GUI.
The `tomcat-users.xml` file is located in tomcatinstallationfolder/conf. ie. `CATALIN_HOME/conf/tomcat-users.xml`
make sure that the tomcat user has `tomcat`, `manager-script`, and `admin` roles
```bash
<user password="tomcat" roles="tomcat,manager-script,admin" username="tomcat"/>
```