Netbeans no longer comes with Tomcat bundled so if you want to deploy your application you need to manually register an external server.
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.
sudo apt update :) (the Linux ritual)
sudo apt install tomcat9 tomcat9-docs tomcat9-examples tomcat9-admin
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" />
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/
USERNAMEwith your Linux username
In the next window, select Apache Tomcat and click next.
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
Click finish, and you should see Tomcat as an added Server under the Server node.