Initial setup of Tomcat and its registration with NetBeans
I needed to configure and run Tomcat on Mac OS X (Mountain Lion) and register this application server (servlet container) with NetBeans. In order to do this, I completed the following points.
Unpack the archive, for example, in the user folder.
~/apache-tomcat-7.0.42
Open the program "Terminal".
Go to the folder "bin"
cd ~/apache-tomcat-7.0.42/bin
and set permissions to run files with the .sh extension.
sudo chmod +x ./*.sh
Set the environment variable CATALINA_HOME. In order for it to be preserved not for the duration of the session in the terminal, but permanently, it is necessary to register it in the file “launchd.conf”. Create / open a file (an example is given using the vi editor, but you can use any other, for example emacs):
sudo vi /etc/launchd.conf
Switch to insert mode: “s key”. Write the text there:
setenv CATALINA_HOME /Users//apache-tomcat-7.0.42
XXX is the name of your user, if you saved tomcat to the user’s folder as indicated in step 2, if not, specify the path to the folder where you saved tomcat. Close the insert mode "Esc key". Switch to the "key:" command mode. Save the file, the command "wq".
By default, the server is configured on port 8080. To change it, go to the “conf” folder:
cd ~/apache-tomcat-7.0.42/conf
Open the file "server.xml" there. Find the tag “Connector” where the port attribute is “8080” and set the port attribute to the desired value:
By default, a user with publishing rights (deploy) to the server via the web GUI or through a script is disabled. It must be written in the file "tomcat-users.xml". To do this, go to the folder "conf":
cd ~/apache-tomcat-7.0.42/conf
Open the “tomcat-users.xml” file there and add the following (the username and password can be used other than those listed):
Restart the computer so that the established environment variable CATALINA_HOME is set.
Open the program "Terminal".
Go to the folder "bin"
cd ~/apache-tomcat-7.0.42/bin
and run the startup.sh script
sh startup.sh
The following should be displayed in the terminal (depending on your system settings):
Using CATALINA_BASE: /Users//apache-tomcat-7.0.42 Using CATALINA_HOME: /Users//apache-tomcat-7.0.42 Using CATALINA_TMPDIR: /Users//apache-tomcat-7.0.42/temp Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home Using CLASSPATH: /Users//apache-tomcat-7.0.42/bin/bootstrap.jar:/Users/XXX/apache-tomcat-7.0.42/bin/tomcat-juli.jar
Start the browser and type in the address period http: // localhost: 8080 . If you changed the port, as indicated in clause 6, then specify your port.
The tomcat homepage should open.
By the button “Server status” you can see the status of the raised server. You will need to enter a username and password created earlier.
By clicking the “Manager App” button you can publish (delete) applications. You will need to enter a username and password created earlier.
The server is stopped as follows. Go to the folder "bin"
cd ~/apache-tomcat-7.0.42/bin
and run the shutdown.sh script
sh shutdown.sh
Register Tomcat Server with NetBeans
If version 8 of Tomcat was installed, it is necessary to make a symbolic link to the library catalog.
In the window that opens, select "Apache Tomcat" and click "Next"
In the next displayed panel, specify the Tomcat home folder, for example "/Users/XXX/apache-tomcat-7.0.42"
Specify the username and password created earlier. Click the Next button.
Specify the port if it has been changed previously. Click the "Finish" button.
For verification, you can create a Web application and select Apache Tomcat as the application server. Then run it from NetBeans. This application will automatically deploy to Tomcat and run in a browser, for example, under the following address: http: // localhost: 8090 / WebApplication1 (usually, by default, the web application template contains a jsp page with the text “Hello World!”).
Note
This does not apply to setting up Tomcat or registering a Tomcat server with NetBeans, but some applications look for java in the / bin folder, and in Mac OS X, java is installed in other folders, but there is a symbolic link to java in the / usr / bin folder. Thus, you need to make another symbolic link to java.