Installing Apache Cocoon
Getting Apache Cocoon
You have three choices for getting Cocoon: you can either download a stable release, or you can download development snapshot, or you can get the latest development version directly from the cvs repository.
Download a distribution
You can simply download the latest official release from the Cocoon distribution directory.
Download a development snapshot
You also can download one of the development snapshots from the CVS snapshots directory.
Step-by-step cvs instructions for Windows
See the Cocoon document Contrib for starting tips.
- Download a recent WinCVS (1.2 or above);
- Install it;
- Start it;
- Click on admin->preferences;
- In "Enter the CVSROOT:" enter ":pserver:anoncvs@cvs.apache.org:/home/cvspublic" (without quotes);
- In "Authentication:" choose "'passwd' file on the cvs server";
- Click "Ok";
- Click admin->login;
- When asked for the password: answer "anoncvs" (without quotes);
- Click "create->checkout module";
- Module name and path on the server is "cocoon-2.1" (no quotes);
- Choose a dir to put the source code in;
- Go to the "Checkout-options" tab and select "By revision/tag/branch" and enter "HEAD";
- Click "Ok";
- If everything goes well, messages will start to appear in the log window;
- Wait until you see "*****CVS exited normally with code 0*****" in the log window;
- The Cocoon source is now on your harddrive.
Step-by-step cvs instructions for Unix
- Start the shell of your choice.
- Enter "cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic login".
- When asked for the password: answer "anoncvs".
- Enter "cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic -z3 checkout -r HEAD cocoon-2.1". This will create a directory called "cocoon-2.1" where the Cocoon2 source will be stored.
- Wait until cvs has finished.
- The Cocoon source is now on your harddrive.
In case you want to update your Cocoon source tree to the current version, change to the "cocoon-2.1" directory and call "cvs -z3 update -d -P".
Configuring Environment
Set JAVA_HOME environment variable
Set the JAVA_HOME environment variable to point to the root directory of the Java Development Kit installed on your machine. To do this simply type:
[unix] JAVA_HOME=/path/to/java/ [win32] SET JAVA_HOME=c:\path\to\java
Your mileage may vary, but you know how to setup environments, right?
Java 1.4 configuration
Cocoon requires more recent versions of the Xerces and Xalan libraries than those shipped with j2se 1.4. To override bundled libraries, follow these steps:
- Create %JAVA_HOME%\jre\lib\endorsed directory. (Tomcat users use %TOMCAT_HOME\common\endorsed instead)
- Copy xercesXXX.jar, xalan-XXX.jar, and the xml-apis.jar from the .\lib\endorsed\ to the new directory created above.
Due to changes in JDBC between JDK 1.3 and JDK 1.4, it is not possible to use Cocoon built on JDK 1.3 with JDK 1.4 when it comes to database connections. Make sure you prepare cocoon with a JDK that matches the one you will deploy on.
JDK Dependency
Cocoon requires a Java compiler for installation and for running some components like XSP etc. For components, the default configuration of Cocoon does not use the compiler in JAVA_HOME, but a version shipped with Cocoon.
UNIX with X server
Cocoon is bundled with the Batik (SVG rasterization toolkit) to deliver SVG imaging capabilities. Batik uses Java java.awt library, which (at least in Sun JDK before 1.4) requires graphics display. This means that X server must be running and Cocoon should have permission to connect to it.
Easiest way to avoid X server connection problem (and to have mentioned permission) is to install and run Cocoon and entire servlet engine of your choice under regular user account.
For security, and many other reasons, X server can be replaced by Xfvb or PJA (alternative awt implementation).
Headless UNIX and PJA
If you are using unix with the Sun JDK 1.4, it can run in the headless environment (but you still must have X libraries installed!) when following option is provided on Java startup:
-Djava.awt.headless=true
export CATALINA_OPTS='-Djava.awt.headless=true'
If you are using unix with the Sun JDK 1.3.1 or earlier, it's awt implementation requires you to use X even if you aren't actually displaying anything. One simple solution is to use a different implementation of the awt.
- From www.eteks.com you can get an awt replacement that doesn't need X: http://www.eteks.com/pja/en/.
- Then add the following options to the Java command starting your container:
-Xbootclasspath/a:/path/to/pja.jar -Dawt.toolkit=com.eteks.awt.PJAToolkit -Djava.awt.graphicsenv=com.eteks.java2d.PJAGraphicsEnvironment -Djava.awt.fonts=/usr/local/jdk/jre/lib/fonts/
export CATALINA_OPTS='-Xbootclasspath/a:/path/to/pja.jar \ -Dawt.toolkit=com.eteks.awt.PJAToolkit \ -Djava.awt.graphicsenv=com.eteks.java2d.PJAGraphicsEnvironment \ -Djava.awt.fonts=/usr/local/jdk/jre/lib/fonts/'
Building Cocoon
Optional functionality
Blocks
Additional "components" in Cocoon 2.1 are now implemented using a partial implementation of a concept called "blocks". Full support (planned for the next release) will include hot-deployable services with java-like extension and inheritance. For this release, blocks are implemented as self contained units of code, samples, files and configuration. Most, if not all optional features have been factored out into blocks and can be neatly included or excluded as a unit.
Most blocks are configured by default to be included in the build, but can be excluded using a local.blocks.properties file.
Some blocks delivered with Cocoon require additional libraries which can not be redistributed with Cocoon (e.g. the Php block). The documentation for these should provide more information, and you should find a "mocks" directory containing non-functional code provided merely to allow compilation.
Optional Jars
Some additional libraries could not be factored ou into a block. For example, the Jakarta Commons HttpClient jar is used by several different optional components, some not in blocks. If you determine that one of these is not necessary for your build, you can eliminate it from your build by removing its entry in lib/jars.xml and removing the jar from lib/optional.
Building a minimal Cocoon
By creating and editing local.build.properties and local.blocks.properties you can remove any unnecessary features you desire.
Running the build
Cocoon uses Jakarta Ant for the build and installation, and comes with a build script ([unix]./build.sh, [win32] .\build.bat) that automates the process.
There are basically two options that can be set as parameters to the script: targets and properties.
About build targets
Targets are the execution units available in Ant build files.
Targets are specified by appending them to the script invocation:
[unix] ./build.sh target1 target2 ... [win32] .\build.bat target1 target2 ...
Cocoon build targets
The build.xml file comes with some basic important targets. If no target is specified, the default one is used (defined in build.xml).
Cocoon targets place work files and results in a build directory under the cocoon root. The only exception are the distribution targets that build in a directory called dist.
The key targets you will use most often are noted below. For a listing of all available targets, run:
[unix] ./build.sh -projecthelp [win32] .\build.bat -projecthelp
build clean
Cleans the build directory. It is recommended to clean Cocoon build directory every time you upgrade Cocoon, or add/remove libraries from the ./lib/optional/ directory, or change JDK version.
build webapp [default]
Builds a Cocoon web application in build/webapp. This is the default target, so running the build script with no arguments calls this target.
build war
Builds a Cocoon web application in build/webapp and packages it as a .war file.
Installing Cocoon
In most servlet engines, this is just a matter of copying the war file or webapp directory to a specific directory and the engine will take care of installing it when restarted.
If those simple instructions do not work as expected, you may find help in some of the container-specific notes below contributed by users:
Installing on Tomcat 3.2.X
Tomcat currently uses a different version of the XML parser than Cocoon. To get Cocoon to work, you need to perform the following steps:
- Stop Tomcat Go to the tomcat/bin directory, and run the shutdown script.
- Delete tomcat/lib/jaxp.jar Tomcat's jaxp.jar is 'sealed', and since xerces contains its own implementation of the JAXP standard extension, Java will fail to load xerces and report a 'Package Sealing Violation' if both are in the classpath.
- Rename tomcat/lib/parser.jar to tomcat/lib/zparser.jar Tomcat's parser.jar contains older versions of some the same XML APIS that Xerces uses, and these will prevent Xerces from functioning properly if they appear before Xerces in the classpath. Since Tomcat's startup scripts automatically load all the jar files in tomcat/lib in name order, changing the name of the file causes it to be loaded last in the classpath.
- Copy the cocoon/lib/core/xerces-XXX.jar and cocoon/lib/core/xml-apis.jar JAR files to tomcat/lib Cocoon will now be able to see and use the correct XML libraries.
- Copy cocoon/build/cocoon/cocoon.war into tomcat/webapps
- Start Tomcat Go to the tomcat/bin directory, and run the startup script.
- Start using Cocoon Access the URI http://localhost:8080/cocoon/ with your favorite browser and start to enjoy the world of Cocoon.
Installing on Tomcat 3.3.X
This is a very easy installation.
- Build the Cocoon webapp as described above.
- Copy cocoon/build/webapp into tomcat/webapps directory, calling it cocoon
- Start Tomcat: Go to the tomcat/bin directory, and run the startup script.
- Open the Cocoon welcome page: http://localhost:8080/cocoon/
- Congratulations! You should see the Cocoon welcome page.
Installing on Tomcat 4.0 - 4.0.1, 4.0.4b1
Tomcat 4 is a really straight-forward installation.
- Build the Cocoon webapp as described above.
- Copy cocoon/build/cocoon/cocoon.war into tomcat/webapps directory.
- Start Tomcat: Go to the tomcat/bin directory, and run the startup script.
- Open the Cocoon welcome page: http://localhost:8080/cocoon/
- Congratulations! You should see the Cocoon welcome page.
Installing on Tomcat 4.0.3
If you have to use Tomcat 4.0.3, you have to replace its XML parser with the one shipped with Cocoon.
- Remove tomcat/common/lib/xerces.jar file.
- Copy following libraries from the cocoon/lib/core directory to the
tomcat/common/lib directory:
- xalan-XXX.jar
- xercesImpl-XXX.jar
- xml-apis.jar
- Copy cocoon/lib/optional/batik-all-XXX.jar to the tomcat/common/lib directory.
- Edit extra-classpath parameter in the cocoon/src/webapp/WEB-INF/web.xml file:
For UNIX:
<init-param> <param-name>extra-classpath</param-name> <param-value>/tomcat/common/lib/xalan-XXX.jar: /tomcat/common/lib/xercesImpl-XXX.jar: /tomcat/common/lib/xml-apis.jar: /tomcat/common/lib/batik-all-XXX.jar</param-value> </init-param>
For Windows:
<init-param> <param-name>extra-classpath</param-name> <param-value>C:\tomcat\common\lib\xalan-XXX.jar; C:\tomcat\common\lib\xercesImpl-XXX.jar; C:\tomcat\common\lib\xml-apis.jar; C:\tomcat\common\lib\batik-all-XXX.jar</param-value> </init-param>
- Clean Cocoon build directory: build clean
- Build Cocoon webapp: build webapp
- Remove xalan-XXX.jar, xercesImpl-XXX.jar, batik-all-XXX.jar, and xml-apis.jar from the cocoon.war archive.
- Copy cocoon/build/cocoon/cocoon.war into tomcat/webapps directory.
- Start Tomcat: Go to the tomcat/bin directory, and run the startup script.
- Open the Cocoon welcome page: http://localhost:8080/cocoon/
- Congratulations! You should see the Cocoon welcome page.
Installing on Tomcat 4.0.4b1 LE with JDK 1.4.0
This combination is also easy to install.
- Build the Cocoon webapp as described above.
- Copy cocoon-2.1/build/cocoon/cocoon.war into tomcat/webapps directory.
- Set environment variable CATALINA_OPTS=-Djava.awt.headless=true
- Start Tomcat: Go to the tomcat/bin directory, and run the startup script.
- Open the Cocoon welcome page: http://localhost:8080/cocoon/
- Congratulations! You should see the Cocoon welcome page.
Installing on BEA Weblogic 6.0sp2
This installs Cocoon using the cocoon.war file. This was successfully installed under Windows 2000 and JDK 1.3.1. Unix users will need to adjust appropriately. If you haven't done so already, build a domain and a server. In this discussion, the name of the domain is 'mydomain', the name of the server is 'myserver', and WebLogic installation directory is c:\bea\wlserver6.0sp2\. These are the BEA defaults.
- Build the Cocoon webapp as described above.
- Copy cocoon\build\cocoon\webapp directory into the c:\bea\wlserver6.0sp2\config\mydomain\applications\ directory of your WebLogic server.
- Copy the xerces-XXX.jar and xml-apis.jar JAR files from the cocoon\lib\core\ to the directory of your choice, say c:\bea\.
- Add to the config.xml of the WebLogic server following snippet:
<Application Deployed="true" Name="Cocoon" Path="./config/mydomain/applications"> <WebAppComponent Name="cocoon" Targets="myserver" URI="cocoon"/> </Application>
- Edit c:\bea\wlserver6.0sp2\config\mydomain\startWebLogic.cmd file, add xerces and xml-apis JAR files to the classpath:
set CLASSPATH=c:\bea\xerces-XXX.jar;c:\bea\xml-apis.jar set CLASSPATH=%CLASSPATH%;.;.\lib\weblogic_sp.jar set CLASSPATH=%CLASSPATH%;.\lib\weblogic.jar
- Start WebLogic server using startWebLogic.cmd.
- Using a browser, you might want to check WebLogic configuration using console: http://localhost:7001/console/.
- Open the Cocoon welcome page: http://localhost:7001/cocoon/ (Don't forget the final '/' in the link.)
- Congratulations! You should see the Cocoon welcome page.
Installing on ServletExec 3.1 (In Process with IIS)
This installs Cocoon in a "war" configuration. This was successfully installed under Windows NT 4.0 and IIS 4. I don't believe that SE is available for unix.
- Install IIS as usual
- Install ServletExec (default paths will be used throughout), but don't start it.
- Build Cocoon's war file (include lib's)
- Copy cocoon.war into C:\Program Files\New Atlanta\ServletExec ISAPI\webapps\default, creating the directory default if required.
- Start IIS.
- Open the Cocoon welcome page (http://localhost/cocoon/)
- Congratulations! (hopefully) you should see the Cocoon welcome page.
Installing on JBoss 2.4.4 with Tomcat 4.0.1 (Catalina)
This section describes the deployment of the Cocoon sample WAR with the JBoss-2.4.4_Tomcat-4.0.1 package. It assumes that you built Cocoon as described above or downloaded the binary Cocoon distribution. All steps have been tested with a fresh JBoss 2.4.4 installation on Linux and Windows 2000.
The JBoss/Tomcat package has the following directory structure
[path]/JBoss-2.4.4_Tomcat-4.0.1/jboss [path]/JBoss-2.4.4_Tomcat-4.0.1/catalina
Subsequently,
- jboss denotes the JBoss-2.4.4_Tomcat-4.0.1/jboss directory
- catalina is short for JBoss-2.4.4_Tomcat-4.0.1/catalina
- and cocoon is the base directory of your Cocoon distribution or CVS checkout.
In order to get Cocoon running you have to install Xerces as default XML parser for JBoss.
- Stop JBoss if it is running.
- Remove the following files from the jboss/lib directory
- crimson.jar
- jaxp.jar
- Copy xml-apis.jar from cocoon/lib/core/ to jboss/lib
- Change jboss/bin/run.sh
[...] # Add the XML parser jar and set the JAXP factory names # Crimson parser JAXP setup(default) # Change it to Xerces for C2 JBOSS_CLASSPATH=$JBOSS_CLASSPATH:../lib/xml-apis.jar # Remove the following two lines JAXP=-Djavax.xml.parsers.DocumentBuilderFactory=\ org.apache.crimson.jaxp.DocumentBuilderFactoryImpl JAXP="$JAXP -Djavax.xml.parsers.SAXParserFactory=\ org.apache.crimson.jaxp.SAXParserFactoryImpl" [...]
- Start JBoss with run_with_catalina.sh or run_with_catalina.bat
- Copy cocoon/build/cocoon/cocoon.war to jboss/deploy
- Check the server log to make sure that J2EE application: [...]/cocoon.war is deployed.
- Open the Cocoon welcome page (http://localhost:8080/cocoon/)
- You should see the Cocoon welcome page.
Installing on JBoss 2.2.2 with Tomcat 3.2.2
This section describes the deployment of the Cocoon sample WAR with the JBoss 2.2.2/Tomcat-3.2.2 package. It assumes that you built Cocoon as described above. All steps have been tested with a fresh JBoss 2.2.2 installation on Linux and Windows ME(sic).
The JBoss/Tomcat package has the following directory structure
[path]/JBoss-2.2.2_Tomcat-3.2.2/jboss [path]/JBoss-2.2.2_Tomcat-3.2.2/tomcat
Subsequently,
- jboss denotes the JBoss-2.2.2_Tomcat-3.2.2/jboss directory
- Tomcat is short for JBoss-2.2.2_Tomcat-3.2.2/tomcat
- and cocoon is the base directory of your Cocoon distribution or CVS checkout.
In order to get Cocoon running you have to install Xerces as default XML parser for JBoss.
- Stop the server if it is running.
- Remove the following files from the jboss/lib directory
- crimson.jar
- jaxp.jar
- xml.jar
- Remove the following files from the tomcat/lib directory
- jaxp.jar
- parser.jar
- Copy xerces-XXX.jar from cocoon/lib/core/ to jboss/lib
- Change jboss/bin/run.sh
[...] # Add the XML parser jars and set the JAXP factory names # Crimson parser JAXP setup(default) # Change it to Xerces for C2 JBOSS_CLASSPATH=$JBOSS_CLASSPATH:../lib/xerces-XXX.jar # Remove the following two lines JAXP=-Djavax.xml.parsers.DocumentBuilderFactory=\ org.apache.crimson.jaxp.DocumentBuilderFactoryImpl JAXP="$JAXP -Djavax.xml.parsers.SAXParserFactory=\ org.apache.crimson.jaxp.SAXParserFactoryImpl" [...]
- Start JBoss with run_with_tomcat.sh or run_with_tomcat.bat
- Copy cocoon/build/cocoon/cocoon.war to jboss/deploy
- Check the server log to make sure that J2EE application: [...]/cocoon.war is deployed.
- Open the Cocoon welcome page (http://localhost:8080/cocoon/)
- Congratulations! (hopefully) you should see the Cocoon welcome page.
Installing on Resin 2.x
This section describes the deployment of the Cocoon sample WAR with Resin 2.x. It assumes that you built Cocoon as described above. All steps have been tested with a fresh Resin 2.0.0, 2.0.4, and 2.1.3 installations (the package is available from Resin's download page)
After unpacking the Resin package you get the following directory structure
[path]... [path]/resin-2.x/conf [path]/resin-2.x/lib [path]/resin-2.x/webapps [path]...
To get Cocoon running do the following:
- Stop the server if it is running.
-
For 2.0.3 version and older: If yours Resin is older then
2.0.4, you have to install Xerces as default XML parser for Resin
- Remove the following files from the resin-2.0.x/lib directory:
- jaxp.jar
- dom.jar
- sax.jar
- Copy xerces-XXX.jar and xml-apis.jar JAR file from cocoon-2.1/lib/core/ to the resin-2.0.x/lib/ directory.
- Remove the following files from the resin-2.0.x/lib directory:
- For 2.0.4 version and newer: Edit resin-2.x/conf/resin.conf, change value of the servlet-classloader-hack element to true
- Copy the cocoon-2.1/build/cocoon/cocoon.war WAR file to resin-2.x/webapps directory
- Start Resin as usual
- Open the Cocoon welcome page (http://localhost:8080/cocoon/)
- Congratulations! (hopefully) you should see the Cocoon welcome page.
Installing on HP-AS 8.X
HP-AS is J2EE application server available from the Hewlett-Packard website. Download and install HP-AS 8.X
- Extract the cocoon.war file to some directory, using WinZIP or a similar utility to extract the files.
- To run HP-AS, go to ( Start | Programs | HP Middleware | HP
Application Server | System Console).
The HP-AS Console appears with a Log browser. As the HP-AS kernel starts and initializes, messages will appear in the status bar of the console. Wait for the message 'Kernel started' to appear in the Log browser. The following message should display:
[10/16/01 16:03:50][localhost_][S]:Kernel "kernel" started. - To verify that an instance of HP-AS is running, open a web browser and go to
http://localhost:9090/helloservlet/hello
An HTML page should appear containing the following message:
Congratulations!
Congratulations from the HelloWorldServlet
It appears you have the server running
My servlet path is /hello
This test is valid only if you've performed a full install of HP-AS - In the HP-AS console, select View | Deployment Window. In
the Available Files pane on the right, browse to the the
directory you extracted the cocoon.war file to.
Expand this directory, and then drag and drop the cocoon sub-directory node to the kernel.j2ee-partition icon in the left pane. - When prompted, answer Yes to the deployment question.
This should create an appropriate entry in the HP-AS j2ee partition configuration file.
In the current version of the console, there is no indication that the operation succeeded. If you see a parser error in the Log browser, ignore it. - To test the deployment, open a web browser and go to the following URL:
http://localhost:9090/cocoon/welcome
Congratulations! (hopefully) you should see the Cocoon welcome page. (this request may take some time).
Installing on JRun 3.1
This section describes the deployment of the Cocoon sample WAR with JRun 3.1, on its default server. It assumes that you built Cocoon as described above. All steps have been tested under Win2000.
To get Cocoon running do the following:
- Stop the default and admin servers if they are running.
- Remove jaxp.jar and parser.jar files (Crimson XML parser) from the jrun/lib/ext/ directory.
- Install Xerces as default XML parser for JRun by copying xerces-XXX.jar and xml-apis.jar JAR files from the cocoon-2.1/lib/core/ to jrun/lib/ext/ directory.
- Update Rhino shipped with JRun with newer version from the Cocoon by overwriting jrun/lib/rhino.jar JAR file with the cocoon-2.1/lib/optional/rhino-1.5r3.jar file.
- Start JRun admin server.
- Start JRun default server.
- Open JRun admin page: http://localhost:8000/
- Deploy cocoon.war webapp using console. Use same values for application name and URI prefix (e.g., application name "cocoon", URI "/cocoon").
- Open the Cocoon welcome page: http://localhost:8100/cocoon/
- Congratulations! (hopefully) you should see the Cocoon welcome page.
cocoon.rootdir=/absolute/path/to/jrun/servers/default/cocoon cocoon.class={webapp.service-class} webapp.mapping./cocoon=cocoon
Installing on iPlanet Web Server 4.x and other engines without context management
iPlanet Web Server 4.x provides the servlet 2.2 API (javax.servlet.* classes), but the servlet engine doesn't handle servlet contexts. This means there is no classloader built with the contents of WEB-INF/classes and WEB-INF/lib and that resolution of context resources (using ServletContext.getResource()) doesn't give the expected results.
To be able to run on such non-compliant engines, Cocoon provides a bootstrap servlet in org.apache.cocoon.BootstrapServletthat handles all the servlet context related behaviours needed for proper functioning.
To use this bootstrap servlet, configure your servlet engine as follows (how to do it depends on the actual engine - see below for iPlanet) :
- add cocoon.jar (and only this one) in the engine's classpath,
- declare the org.apache.cocoon.servlet.BootstrapServlet servlet,
- add a "context-directory" parameter, whose value is the absolute path to Cocoon's context (e.g. "/path/webapp/cocoon"),
- add any other cocoon parameters you want to this servlet (see web.xml for a description of available parameters),
- configure a path translation from "/" to the servlet.
For iPlanet Web Server 4.x, this translates to :
- connect to the administration server of your web server,
- in the "Servlet" tabs, select "Configure servlet attributes", and enter the
following :
- Servlet Name : cocoon
- Servlet Code (class name) : org.apache.cocoon.servlet.BootstrapServlet
- Servlet Classpath : /path/webapp/cocoon/WEB-INF/lib/cocoon.jar
- Servlet Args : context-directory=/path/webapp/cocoon (and any other Cocoon parameters you want)
- select "Configure Servlet Virtual Path Translation" and enter the following
:
- Virtual Path : @/.*
- Servlet Name : cocoon
- save and apply your changes, and enjoy the latest Cocoon on an old-fashioned servlet engine!
Installing on WebSphere 4.0
This section describes the deployment of the Cocoon sample WAR with WebSphere 4.0, on its default server. It assumes that you built Cocoon as described above. All steps have been tested under Win2000 and WebSphere AEs 4.0.1 a0136.02.
To get Cocoon running do the following:
- Start the server using startServer startup script.
- Open admin page: http://localhost:9090/admin/
- Deploy cocoon.war webapp using console.
- Save server configuration file.
- Restart the server using stopServer and startServer scripts.
- Open the Cocoon welcome page: http://localhost:9080/cocoon/
- Congratulations! (hopefully) you should see the Cocoon welcome page.
Errors and Improvements? If you see any errors or potential improvements in this document please help us: View, Edit or comment on the latest development version (registration required).