Setting up Confluence on Debian 5.0.3 (Lenny)

I just spent 2 hours trying to figure out how to fix the error message

Configuring the database failed. 
Couldn't create the database schema. 
Invalid bean definition with name 'luceneConnection' defined in class path resource [indexingSubsystemContext.xml]: 
Could not resolve placeholder 'lucene.index.dir' 

while installing Confluence so I thought I would share the solution to the problem.

Add non-free to the /etc/apt/sources.list. As an example, your sources file might look like

deb http://ftp.iinet.net.au/debian/debian/ lenny main non-free contrib
deb-src http://ftp.iinet.net.au/debian/debian/ lenny main non-free contrib
deb http://security.debian.org/ lenny/updates main non-free contrib

Now install java, the required xlibs and the lucene java lib with the command

aptitude install libx11-6 libx11-dev libxt6 libxt6-dbg libxext6 libxtst-dev libxtst6 xlibs-dev sun-java6-jdk liblucene2-java

Create the database using utf8 as the character set by logging into the mysql command line interface and running

CREATE DATABASE confluence CHARACTER SET utf8 COLLATE utf8_bin;

Get the mysql-java driver and install it with

wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.10.tar.gz
cd mysql-connector-java-5.1.10
mkdir /usr/local/confluence/
mkdir /var/lib/confluence
cp *.jar /usr/local/confluence/lib/

Get the standalone confluence tar file from the Atlassian site and extract it, then copy its contents to /usr/local/confluence with cp -a (to preserve file permissions). As per the Installation guide, edit the /usr/local/confluence/confluence/WEB-INF/classes/confluence-init.properties file and add the line confluence.home=/var/lib/confluence/ to it so it can find the confluence home directory Now we need to setup our environment variables so that tomcat knows where to find java and the shared java classes (or more specifically the lucene java class to fix the error above). To do this run

export JAVA_HOME="/usr"
export CLASSPATH="/usr/share/java"

Now you should be able to run the /usr/local/confluence/bin/startup.sh script to start the server and actually be able to get through the installation