Installing and adding an External Tomcat server in Netbeans 6.0
Apache Tomcat is one of the most popular web servers available today. Since the Milestone 9 preview build for Netbeans 6.0 does not have Tomcat bundled, users will need to manually register an external Tomcat server. This guide will show a step-by-step process on how to add an external Tomcat server to NetBeans 6.0.
- You should have the latest Netbeans 6.0 with Web and Java EE feature installed.
- You should have the latest JDK version installed.
- You need to download Apache Tomcat 5.5 or Tomcat 6
- Verify the that all the script files in $TOMCAT/bin are executable.
- See Issue 151222 for detailed information
Note: Download the zip version of the Tomcat server since you will not be able to add a Tomcat server if you have installed it using the Windows Installer.
Installing and Setting up
1. Extract the contents of the Tomcat zip file to a folder in your disk. This should create a directory that would look something like this:
Note: In this guide, $TOMCAT refers to the root Tomcat installation directory.
2. Since Tomcat does not come bundled with any default users that could be used for administrative purposes we need to add a user with the proper roles assigned to it.
Go into your $TOMCAT/conf/ folder and open tomcat-users.xml in a text editor. Add a username and password to the list of users in the file with a 'manager' role assigned to that user.
Here is how your tomcat-users.xml should look like:
<?xml version='1.0' encoding='utf-8'?> <tomcat-users> <role rolename="manager"/> <role rolename="standard"/> <user username="admin" password="pwd" roles="standard,manager"/> </tomcat-users>
This will add a user 'admin' with the password 'pwd' who has 2 roles assigned to it namely 'standard' and 'manager'. Please change the password according to your preference. Once done, save and close the file.
Later on we will see that Netbeans requires a username and password associated with a manager role when we try to add a server.
3. This step is only for users who are trying to add Tomcat 6 (versions 6.0.10 and lower) as an external server. If you are using one of these versions you should be aware of this issue.
There are 2 workarounds for this issue:
- Either create the following two directories in $TOMCAT/conf/ folder:
- Or, use a custom basedir instead of the default one. If you have no idea what this means don’t worry and just follow the instructions in the first option.
(Please note that Tomcat versions 6.0.13 and higher do not require this step.)
Adding an External Server
Once you have Tomcat installed and properly setup we can go ahead and open up Netbeans to add Tomcat as an external server.
1. The first step is to start up Netbeans and open up the Runtime tab in the right panel. Right click on the Servers node and in the context menu click on Add server.
2. Select Tomcat 6.0 or Tomcat 5.5 depending on which version you are using and click Next.
3. Browse and select the Tomcat installation directory. This should be the root Tomcat directory, i.e. if you have installed Tomcat at C:\Tomcat5.5\ then this should be what you would browse and select.
If you are using a custom base directory then select ‘Use Private Configuration Folder’, browse to the base directory and select it.
Next put in the user name and password that we added in the tomcat-users.xml file at the beginning of this article.
4.Click Finish. You should now be able to see Tomcat as an added server under the Servers Node.
This concludes this article on installing and adding external Tomcat servers. For deploying applications on these servers you might want to take a look at this article on Deploying to an External Tomcat server .