There are three steps to installing cocoon with tomcat as service.

1. Installation of Java Development Kit (I am using JDK1.3)    Download j2sdk-1_3_1_01-win.exe
2. Installation of Tomcat (I am using 4.1.24)                            Download tomcat-4.1.24.exe
3. Installation of Cocoon (I am using 2.1.5.1)                          http://apache.mirrors.ilisys.com.au/cocoon/cocoon-2.1.5.1-src.zip

Installation of Java Development Kit

It is worthwhile to check what version of JVM you have.  Use java -version in DOS window to see the output.

C:\>java -version
java version "1.4.2_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)
Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)

Experience tells me that Tomcat and Cocoon cannot run as service with JVM version 1.4.2.
Note that, I used java -version command while in the root directory. It showed me the JVM (that comes with windows operating system)'s version.
I am not interested in that. If you have JDK already installed, change directory to jdk installation directory. Mine is c:\local\jdk\bin

C:\>cd local\jdk\bin

C:\local\jdk\bin>

Use the same command "java -version" to verify that you have jdk 1.3.1x installed in your system.

:\local\jdk\bin>java -version
java version "1.3.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)

If you don't have JDK1.3, you can download it from here.

http://smpclientupdate.uow.edu.au/j2sdk-1_3_1_01-win.exe (32MB)

Download the setup program from the above URL and install it.

Setting Environment Variables PATH, JAVA_HOME and CATALINA_HOME
Once the installation is complete, it is a better idea to update the PATH environmental variable.
To do so right click on My Computer icon in the desktop. Click Properties. Click on Advanced tab. Click Environment Variables button in the Advanced property page.

Select the environment variable PATH and click Edit button.
There will be another dialog appearing with two text fields. Position your cursor to the end of the second textfield and type the following assuming you installed JDK in c:\local\jdk :    XXX;c:\local\jdk\bin where XXX stands for the original path.

Since you are already there why not do something else you will need to do later.
Setting the environment variable JAVA_HOME.  Click on the New... button this time.
The dialog box with two textfields appears again. Type JAVA_HOME in the top textfield and in the bottom one, type c:\local\jdk.
Again, it is assuming you installed jdk in c:\local\jdk folder.

Unless you had previously installed tomcat, you will have to click on New... button
Set CATALINA_HOME environment variable, in my case the value I gave was c:\local\tomcat 

Installation of Tomcat

I am using Tomcat 4.1.24 in my computer.
When you install Tomcat, choose a diretory to install. If you set CATALINA_HOME variable already, make sure you install in the same directory.
My tomcat is installed in C:\local\tomcat. When given the option, click the checkbox to install Tomcat as service.

If you missed out on installation of tomcat as service and want to do so. Run tomcat -? in DOS and you will be given command line options that can be used. One of them is "-install".

The default port for Tomcat is 8080, choose another port to suit your needs. I use port 80 (default HTTP port).
Verify your tomcat installation, http://localhost should display tomcat welcome page.

Installation of Cocoon

Download the latest version of Cocoon from http://cocoon.apache.org/

The direct link to cocoon-2.1.5.1 is http://apache.mirrors.ilisys.com.au/cocoon/cocoon-2.1.5.1-src.zip

Extract the .zip file to c:\local. Using the dos window go to cocoon-2.1.5.1 directory.
Execute the following commands

C:\> cd local
C:\local>cd cocoon-2.1.5.1
C:\local\cocoon-2.1.5.1>build


There is a build.bat file that already there. The build file requires you to have JAVA_HOME environment variable set up.
It will take from 4 to 10 minutes for the whole installation.
To verify that your cocoon is ready to use, type

 C:\local\cocoon-2.1.5.1>cocoon servlet

It will display a message saying the server is running at port 8888.
Type http://localhost:8888 in your browser to view the welcome page.

If everything is working well, close it (the dos window), the server will stop.

Putting them altogether

Your tomcat is running, your cocoon is running. All we need to do is put them together into one. Using windows explorer, browse to the folder
C:\local\cocoon-2.1.5.1\build
Copy the folder called webapp inside the build folder, and paste in the folder  C:\local\tomcat\webapps
Rename webapp to cocoon.

It is safe to stop Tomcat service before doing this. To stop Tomcat
from the command line type
C:\>net stop "Apache Tomcat 4.1"
or alternatively, click on Start, Click Run..., type services.msc and press Enter. There will be a service manager window appearing. You can stop or start the various windows services using this.

Once you finish copying the cocoon webapp folder from c:\local\cocoon-2.1.5.1\build to c:\local\tomcat\webapps.

Start your tomcat service by typing net start "Apache Tomcat 4.1" in the command line or use Service Manager (services.msc) and start the service called Apache Tomcat 4.1. You can choose various actions by selecting the service name and right clicking on it. It will show you the list of actions that can be performed with it.

Q: What do I do with c:\local\cocoon-2.1.5.1 folder?
Ans: Delete it, you don't need it for your future cocoon developments. You have to put all your cocoon projects under the folder c:\local\tomcat\cocoon\ assuming that you changed webapp to cocoon after copying the cocoon webapp folder.

 

Enjoy!
or email me: suresh_at_uow_dot_edu_au if you have any faced any problems during the installation.

 

Last Modified: