Initial setup of Tomcat and its registration in 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 have completed the following points.

Install Tomcat

  1. Download the Tomcat archive from here .
  2. Unpack the archive, for example, in the user folder.
    ~/apache-tomcat-7.0.42
  3. Open the "Terminal" program.
  4. Go to the bin folder
    cd ~/apache-tomcat-7.0.42/bin
    and set permission to run files with the extension .sh.
    sudo chmod +x ./*.sh
  5. Set the environment variable CATALINA_HOME. In order to save it not for the duration of the session in the terminal, but permanently, you need 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 described in step 2, if not, then specify the path to the folder where you saved tomcat.
    Close the "Esc key" insert mode.
    Switch to the "key:" command mode.
    Save the file, the command "wq".
  6. 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 server.xml file there.
    Find the “Connector” tag where the port attribute is “8080” and set the port attribute to the value you need:
  7. By default, a user who has the rights to publish (deploy) to the server through the web GUI or through a script is disabled. It must be registered in the file "tomcat-users.xml". To do this, go to the "conf" folder:
    cd ~/apache-tomcat-7.0.42/conf

    Open the "tomcat-users.xml" file there and add the following (you can use a different username and password than the ones given):

  8. Restart the computer so that the set CATALINA_HOME environment variable is set.
  9. Open the "Terminal" program.
  10. Go to the bin folder
    cd ~/apache-tomcat-7.0.42/bin
    and run the script “startup.sh”
    sh startup.sh

    The following should appear 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
    

  11. Launch the browser and type in the address period http: // localhost: 8080 . If you changed the port, as indicated in paragraph 6, then specify your port.
  12. The tomcat home page should open.
  13. Using the “Server status” button, you can see the status of the raised server. You will need to enter the username and password created earlier.
  14. The “Manager App” button allows you to publish (delete) applications. You will need to enter the username and password created earlier.
  15. Server shutdown is performed as follows. Go to the bin folder
    cd ~/apache-tomcat-7.0.42/bin
    and run the shutdown.sh script
    sh shutdown.sh



Register Tomcat Server in NetBeans

  1. If version 8 of Tomcat was installed, then you need to make a symbolic link to the library directory.
    
    ln -s /Users/XXX/apache-tomcat-8.0.0-RC3/lib /Users/XXX/apache-tomcat-8.0.0-RC3/common/lib
    
  2. Open NetBeans
  3. Menu Tools-> Servers
  4. In the window that opens, click the "Add Server" button
  5. In the window that opens, select "Apache Tomcat" and click "Next"
  6. In the next panel displayed, specify the Tomcat home folder, for example, "/Users/XXX/apache-tomcat-7.0.42"
  7. Specify a username and password created earlier. Click the “Next” button.
  8. Specify the port if it has been changed before. Click the Finish button.
  9. For verification, you can create a Web application and select Apache Tomcat as the application server. Then launch it from NetBeans. This application will automatically deploy to Tomcat and start 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 in NetBeans, but some applications look for java in the / bin folder, and on 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.

sudo ln -s /usr/bin/java /bin/java

Also popular now: