Archive

Archive for the ‘Tomcat’ Category

Eclipse with Tomcat

January 4th, 2009

I am going to use Eclipse for development. Because I am also going to use Flex I installed Flex Builder 3 which is actually a  version of Eclipse pre-configure by Adobe to contain Flex. I try to update Flex Builder with the necessary plugins, and also connect it to Tomcat. This is quite difficult task as I found while searching for help on the internet. The common advise I found to avoid complications is to have installed Flex Builder, and also Eclipse. So, I have both of them. 

To install Eclipse is a fact to go to the Eclipse website and choose the package you want to install and follow the instructions. 

To use Tomcat as a web server for the projects created with Eclipse I follow the instruction found this article: Eclipse WTP and Tomcat Tutorial. This article includes a link to a explanatory screencast. Eclipse IDE can start, reload, and stop Tomcat, and the projects become web application spaces automatically. It also allows to create ‘WAR’ files in order to deploy the application in another server.

Following the article instruction I found some problems. The first one was related to a message which Tomcat was displaying while starting. The message is: INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path. The article OSX: The Apache Tomcat Native library… was not found on the java.library.path help me to solve this problem.

The next problem was related to Tomcat and the context properties. I solve this with the indications found in this article: WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property

Another problem was related to the code in the example servlet ‘HelloWorld’. The tutorial will use this line of code: 

PrintWriter writer = response.getWriter();

This will display the error: ‘PrintWriter cannot be resolved to a type’. This is solved by adding this code in the ‘import’ part of the file:

import java.io.PrintWriter;

I have Eclipse now using tomcat.

Eclipse, Installations, Tomcat, Workstation

The web application space

December 31st, 2008

One of the easy options to start developing in tomcat is to start drooping files in the <Tomcat Home>/webapps/ROOT folder. However, if you are planning to create deployable applications (.war) it is better to create a web application space in to tomcat. The process is not complicated, I found great help reading and following the indication in these web articles: Deploying Web Applications to TomcatDemystifying Tomcat 4’s server.xml FileHow to Create a Web Application in Tomcat Sever? 

In summary what it is necessary to do is the following:

  1. Create a folder for you new application in the <Tomcat Home>/webapps/ folder. Lets call it ‘newapp’.
  2. Inside newapp create the folder ‘WEB-INF’.
  3. Inside WEB-INF create the folders: classes and lib.
  4. Also create a file called ‘web.xml’ and put the following text in it: 
    <?xml version="1.0" encoding="ISO-8859-1"?>
    
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
    
    <web-app>
    </web-app>
  5. Open to edit the file <Tomcat Home>/conf/server.xml and add the node <Context path=”/newapp” docBase=”newapp” debug=”0″ reloadable=”true” /> as a child of  the node <Host> and save it.
  6. For testing purposes create a file in <Tomcat Home>/webapps/newapp called test.jsp with this code in it: 
    <%
    	String message="Hello world!";
    %>
    <%= message %>
  7. Open you favorite internet navigator go to http://localhost:8080/newapp/test.jsp
  8. You have now a new web application space in tomcat.

It is possible to have many web application spaces in tomcat.

    Tomcat

    Ant in Workstation

    December 18th, 2008

    Apache Ant is a Java-based build tool which Tomcat uses to deploy web applications. More info here: http://ant.apache.org. The steps I used to install Ant in the MacBook are:

    Download ANT from http://ant.apache.org/bindownload.cgi .
    Extract the Ant files into the folder you want to install it.
    Add the Ant /bin path to you ~/.profile file. In my case I added this line:
    export PATH=/Users/italoosorio/Tomcat/Ant-home/bin:$PATH 

    I am installing everything related to Tomcat development in my home/Tomcat folder.

    Helpful link:

    - http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variable/

    Ant, Installations, Tomcat, Workstation

    Tomcat in Workstation

    December 18th, 2008

    I decided to continue using JAVA as a programing language. I am using my laptop as developing environment, so I needed to install Tomcat in it. I followed the indication found in this web page: Installing Apache Tomcat 6 on Mac OS X Leopard. A summary of the steps used are the following:

    Set the JAVA_HOME environment variable

    Adding in the file ~/.profile the folling lines and restart the terminal:
    export JAVA_HOME=/Library/Java/Home
    export CATALINA_HOME=/Library/Tomcat/Home

    Download and install the Tomcat binarie

    Download Tomcat from the Apache Tomcat 6 Downloads Page
    Change directories to the folder where you want to install Tomcat.
    Create the Tomcat directory and set an appropriate owner and group:
    > mkdir Tomcat
    > chown <username> Tomcat
    > chgrp admin Tomcat
    Change directories to the newly created Tomcat directory and unpack the tar.gz files
    > cd Tomcat
    > tar -xvzf ~/Downloads/apache-tomcat-6.0.x.tar.gz
    Create a symbolic link that will always point to the current version Tomcat directory
    > ln -s apache-tomcat-6.0.x Home

    Edit tomcat-users.xml configuration file

    Change directories to the Tomcat configuration directory
    > cd Home/conf
    Edit the tomcat-users.xml file
    > nano tomcat-users.xml
    Add the following before </tomcat-users>, where <admin> is the administrator name you assign and <password> is the password. 
    <user username=”<admin>” password=”<password>” roles=”standard,manager,admin”/> 
    Save the tomcat-users.xml file and quit the editor

    Run and Test

    Change directories to where the Tomcat startup scripts are located
    > cd ../bin
    Remove the .bat scripts and .exe executables
    > rm *.bat *.exe
    Execute the Tomcat startup script
    > ./startup.sh
    Test in you navigator entering http://localhost:8080
    To stop Tomcat execute the strip shutdown.sd
    > ./shutdown.sh

     

    I am not planning to have Tomcat as daemon process, I wan to activate it manually.

    Installations, Tomcat, Workstation