Installing Tomcat server in Netbeans 12

As most people already know, Netbeans no longer comes with Tomcat bundled so if you want to deploy your application you need to manually register an external server.

Assumptions

I’m assuming you are using at least:

Netbeans 12.0 installed…


This content originally appeared on DEV Community and was authored by Benjamin Thorpe

As most people already know, Netbeans no longer comes with Tomcat bundled so if you want to deploy your application you need to manually register an external server.

Assumptions

I’m assuming you are using at least:

  • Netbeans 12.0 installed and you are using Linux
  • You have the Java Web Applications plugin installed.
  • You know some basic terminal commands
  • I also assume that you want to install and configure Tomcat from the repository.

If you don’t care an easier method would be to just download apache-tomcat.zip from the Tomcat website, extract the archive to a folder under your home directory and just skip to step 4 of this tutorial.

1. Installing Tomcat

sudo apt update :) (the Linux ritual)

sudo apt install tomcat9 tomcat9-docs tomcat9-examples tomcat9-admin 

2. Add admin user in Tomcat

By default, Tomcat does have any users defined that could be used for administrative purposes, so we need to edit tomcat-users.xml and add a user with the proper roles assigned to it.

sudo xed /etc/tomcat9/tomcat-users.xml

Add the lines below in tomcat-users.xml.

  <!-- user manager can access only manager section -->
  <role rolename="manager-gui" />
  <user username="username" password="_SECRET_PASSWORD_" roles="manager-gui" />

  <!-- user admin can access manager and admin section both -->
  <role rolename="admin-gui" />
  <user username="username" password="_SECRET_PASSWORD_" roles="manager-gui,admin-gui" />

3. Allow Netbeans to read the tomcat Configuration

Unfortunately Netbeans doesn’t correctly detect the the Tomcat installation directory.
We need to make sure that the configuration files can be read from the installation directory otherwise will get an error saying “The <CATALINA_HOME>/conf/server.xml can’t be read.”

sudo ln -s /etc/tomcat9/ /usr/share/tomcat9/conf

We need to change permission on the Tomcat installation directory so we don't face any permission issues.

sudo chown -R USERNAME /etc/tomcat9/
sudo chown -R USERNAME /usr/share/tomcat9/

change USERNAME with your Linux username

4. Adding Server in Netbeans

Now that Tomcat is installed and configured we can open up Netbeans and under the Services tab right click on the Servers and click on Add server.
nbserver

In the next window, select Apache Tomcat and click next.
Under Server Location enter the tomcat directory, by default it should be /usr/share/tomcat9. Also add your username and password that you used in the tomcat-users.xml file.addserver

Click finish, and you should see Tomcat as an added Server under the Server node.


This content originally appeared on DEV Community and was authored by Benjamin Thorpe


Print Share Comment Cite Upload Translate Updates
APA

Benjamin Thorpe | Sciencx (2021-03-12T06:29:39+00:00) Installing Tomcat server in Netbeans 12. Retrieved from https://www.scien.cx/2021/03/12/installing-tomcat-server-in-netbeans-12/

MLA
" » Installing Tomcat server in Netbeans 12." Benjamin Thorpe | Sciencx - Friday March 12, 2021, https://www.scien.cx/2021/03/12/installing-tomcat-server-in-netbeans-12/
HARVARD
Benjamin Thorpe | Sciencx Friday March 12, 2021 » Installing Tomcat server in Netbeans 12., viewed ,<https://www.scien.cx/2021/03/12/installing-tomcat-server-in-netbeans-12/>
VANCOUVER
Benjamin Thorpe | Sciencx - » Installing Tomcat server in Netbeans 12. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/03/12/installing-tomcat-server-in-netbeans-12/
CHICAGO
" » Installing Tomcat server in Netbeans 12." Benjamin Thorpe | Sciencx - Accessed . https://www.scien.cx/2021/03/12/installing-tomcat-server-in-netbeans-12/
IEEE
" » Installing Tomcat server in Netbeans 12." Benjamin Thorpe | Sciencx [Online]. Available: https://www.scien.cx/2021/03/12/installing-tomcat-server-in-netbeans-12/. [Accessed: ]
rf:citation
» Installing Tomcat server in Netbeans 12 | Benjamin Thorpe | Sciencx | https://www.scien.cx/2021/03/12/installing-tomcat-server-in-netbeans-12/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.