Personal tools
You are here: Home GNU / Linux Debian 4.0 Etch Install Cocoon 2.1.x and FOP 0.9x on Debian 4.0 Etch
Document Actions
  • Send this page to somebody
  • Print this page
  • Add Bookmarklet

Install Cocoon 2.1.x and FOP 0.9x on Debian 4.0 Etch

by Pierre-Yves Landuré last modified 2008-09-10 09:40

The 2.1.x versions of Cocoon make use of FOP 0.20.5, a outdated version of this FO processor (FO is a XML standard for printed documents description). This guide help you to replace FOP 0.20.5 by the newer FOP 0.9x.

Installing Java

Cocoon and FOP are Java software. In order to make them work, we need to install the Sun Java virtual machine :
/usr/bin/apt-get install sun-java5-jdk sun-java5-fonts

We set it up as the default Java virtual machine :

/usr/sbin/update-java-alternatives --set java-1.5.0-sun

We also need to install Java Advanced Imaging (JAI), since it is mandatory with the version of FOP provided by Cocoon, as described in this link :

In order to do this, we download the i586 binaries of JAI :

/usr/bin/wget \

We make the downloaded file runable :

/bin/chmod +x /tmp/jai-1_1_3-lib-linux-i586-jdk.bin

We change directory to the Sun JDK home :

cd /usr/lib/jvm/java-1.5.0-sun/

And we run the JAI installer :


Once the install ended, you can remove the downloaded file :

/bin/rm /tmp/jai-1_1_3-lib-linux-i586-jdk.bin

Building FOP 0.9x

First, we install Ant :

/usr/bin/apt-get install ant ant-optional

Then choose the version of FOP to install :


Download the sources :

/usr/bin/wget$FOP_VERSION-src.tar.gz \

Untar the sources:

/bin/tar --directory /tmp -xzf /tmp/fop-$FOP_VERSION-src.tar.gz

Change directory to the created folder :

cd /tmp/fop-$FOP_VERSION

Build the FOP jars :

/usr/bin/ant package

Building XML Graphics Commons

XML Graphics Commons is a dependency of FOP 0.9x and is not available in Cocoon 2.1.x. We need to integrate it manually.

First, choose the version of XML Graphics Commons to install :


Download the sources :

/usr/bin/wget$XGC_VERSION-src.tar.gz \

Untar the downloaded file :

/bin/tar --directory /tmp -xzf /tmp/xmlgraphics-commons-$XGC_VERSION-src.tar.gz

Change directory to the created folder :

cd /tmp/xmlgraphics-commons-$XGC_VERSION

Build the jars :

/usr/bin/ant package

Building Cocoon 2.1.x

Now, we need to customize Cocoon sources to integrate the two softwares we just build. First, choose the version of Cocoon you want to install :


Then, download the sources :

/usr/bin/wget$VERSION-src.tar.gz \

Untar the downloaded file :

/bin/tar --directory /tmp/ -xzf /tmp/cocoon-$VERSION-src.tar.gz

Replace FOP 0.20.5 jar by FOP 0.9x one :

/bin/rm /tmp/cocoon-$VERSION/lib/optional/fop-0.20.5.jar
/bin/cp /tmp/fop-$FOP_VERSION/build/fop.jar /tmp/cocoon-$VERSION/lib/optional/fop-$FOP_VERSION.jar

Add Xml Graphics Commons jar file :

/bin/cp /tmp/xmlgraphics-commons-$XGC_VERSION/build/xmlgraphics-commons-$XGC_VERSION.jar /tmp/cocoon-$VERSION/lib/optional/

Edit the jars.xml file listing all Jars available in Cocoon :

/bin/sed -i \
-e "s/fop-0.20.5/fop-$FOP_VERSION/g" \
-e "/<\/jars>/i\
<title>XML Graphics Commons</title>\\
XML Graphics Commons jar, needed by FOP 0.94\\
<used-by>FOP serializer (fop block)</used-by>\\
" /tmp/cocoon-$VERSION/lib/jars.xml

Edit the gump.xml file to insert the XML Graphics Commons jar in the final WAR file :

/bin/sed -i -e '/<library name="fop"\/>/a\
<library name="xmlgraphics-commons"/>' /tmp/cocoon-$VERSION/gump.xml

Download the customized FOPSerializer source for FOP 0.9x (it is a modified version of Cocoon 2.2.x FOPNGSerializer) :

/usr/bin/wget \

Change directory to the Cocoon sources folder :

cd /tmp/cocoon-$VERSION

And build Cocoon WAR file :

/bin/sh war

Installing with Tomcat 5

We install Cocoon in a Tomcat 5 environment. First, install Tomcat :

/usr/bin/apt-get install tomcat5

Now, copy the Cocoon WAR file in the Tomcat webapps folder :

/bin/cp /tmp/cocoon-$VERSION/build/cocoon/cocoon.war /var/lib/tomcat5/webapps/

Download the Tomcat security policy for Cocoon :

/usr/bin/wget \

Restart Tomcat 5 to enable the new configuration :

/etc/init.d/tomcat5 restart

Cocoon is now available at : http://localhost:8180/cocoon/

Clean Up

You can now remove the downloaded files and sources :

/bin/rm /tmp/fop-$FOP_VERSION-src.tar.gz
/bin/rm -r /tmp/fop-$FOP_VERSION
/bin/rm /tmp/xmlgraphics-commons-$XGC_VERSION-src.tar.gz
/bin/rm -r /tmp/xmlgraphics-commons-$XGC_VERSION
/bin/rm /tmp/cocoon-$VERSION-src.tar.gz
/bin/rm -r /tmp/cocoon-$VERSION



Erreur dans l'url des sources FOP

Posted by Nowicki Christophe at 2008-09-10 09:26

Il y'a une petite typo dans l'url de fop :

/usr/bin/wget$FOP_VERSION-src.tar.gz \

Les fichiers ont été déplacées dans le répertoire source.


Merci pour l'info

Posted by Pierre-Yves Landuré at 2008-09-10 09:46
Merci de m'avoir signalé cette erreur. J'ai corrigé le problème.

J'espère que cet article t'as aidé.

Lone wolf


Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: