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 folder

  • Next, Open Netbeans Editor

  • select the Services tab, Service is located in the left side navigation with multiple tabs Projects, Files, and Services.

  • The services tab shows you a tree of options.

  • Select Servers, Right click on it, and select Add Server only option

  • It opens the Add Server Instance window, Select the Apache Tomcat or TomEE option

  • Click 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
  • 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 tab

  • Click on the Servers option

  • Under Servers, Select the Apache Tomcat or TomEE option and right-click on it

  • It shows a context menu with all options

    • Start : Starts the tomcat server at listening default port 8080
    • Stop: Stops the server
    • Restart: stop and start the server
    • Refresh: 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 performance
    • Remove: Remove the tomcat profile from the Servers option
    • Rename: Rename the profile with a new name
    • View Server Logs: Server logs
    • View Server Output: server output console logs
    • Properties: 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+ select General tab
    • Check the Proxy Settings checkbox value to No Proxy
    • Save changes
  • 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"/>
```