Jackrabbit On Tomcat 6

Prerequisites

Ubuntu setup

apt-get install mysql-server sun-java6-jdk tomcat6 tomcat6-admin libmysql-java
ln -s /usr/share/java/mysql.jar /usr/share/tomcat6/lib/mysql.jar

Note: I am using the http://ourdelta.org version of MySQL - will work with any version though

JCR

Make sure jcr-2.0.jar is in /usr/share/tomcat6/lib (don't link it to /var/lib/tomcat6/lib as well as the other tomcat libraries - this seemed to cause problems)

cd /usr/share/tomcat6/lib
wget http://mirrors.ibiblio.org/pub/mirrors/maven2/javax/jcr/jcr/2.0/jcr-2.0.jar

Jackrabbit Installation

Copy the jackrabbit war to webapps directory

wget http://www.apache.org/dist/jackrabbit/1.6.4/jackrabbit-webapp-1.6.4.war
cp jackrabbit-webapp-1.6.4.war /var/lib/tomcat6/webapps/jackrabbit.war

Note: please use mirror

You can now go to http://localhost:8080/jackrabbit and you should see the welcome page. Create a standard default repository (mine is called "jackrabbit") When creating a default repository, make sure the directory is writeable for Tomcat. Otherwise you will get messages like 'content repository already exists', however, it doesn't. E.g. the default repository would be created in /var/lib/tomcat, so change the owner to user tomcat

chown -R tomcat6:tomcat6 /var/lib/tomcat6

Customisation for Mysql

Create Mysql database (mine is called jackrabbit here with standard user/password):

mysqladmin -u root create jackrabbit
mysql -u root jackrabbit -e "GRANT ALL ON jackrabbit.* TO 'jackrabbit'@'localhost' IDENTIFIED BY 'jackrabbit'"

Ok, this is the fiddly part. Edit /var/lib/tomcat6/temp/jackrabbit and do either 1. or 1. & 2.

1. PersistenceManager

This stores all the repository in mysql - all the file config is still on the file system. Find all the occurances of something like this:

<PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.DerbyPersistenceManager">
  <param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/>
  <param name="schemaObjectPrefix" value="${wsp.name}_"/>
</PersistenceManager>

and change them to

<PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.MySqlPersistenceManager">
  <param name="url" value="jdbc:mysql://localhost:3306/jackrabbit"/>
  <param name="user" value="jackrabbit" />
  <param name="password" value="jackrabbit" />
  <param name="schema" value="mysql"/>
  <param name="schemaObjectPrefix" value="pm_someuniqueprefix_"/>
</PersistenceManager>

2. DbFileSystem

This part is optional, but if you do this everything is stored in the mysql database. Find all the occurances of something like this:

<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
  <param name="path" value="${rep.home}/repository"/>
</FileSystem>

and replace with this:

<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
  <param name="driver" value="com.mysql.jdbc.Driver"/>
  <param name="url" value="jdbc:mysql://localhost:3306/jackrabbit"/>
  <param name="user" value="jackrabbit"/>
  <param name="password" value="jackrabbit"/>
  <param name="schema" value="mysql"/>
  <param name="schemaObjectPrefix" value="fs_someuniqueprefix_"/>
</FileSystem>

Make sure you change the part someuniqueprefix to something unique for the type of repository configuration item you are modifying (ie. workspace, versioning etc)

Cleanup & Test

Now delete the version, workspaces and repository directories and redeploy the app (or restart tomcat if you like)

rm -rf /var/lib/tomcat6/temp/jackrabbit/version /var/lib/tomcat6/temp/jackrabbit/workspaces /var/lib/tomcat6/temp/jackrabbit/repository
/etc/init.d/tomcat6 restart

If everything worked, if you issue the command

mysql -u jackrabbit -pjackrabbit jackrabbit -e "show tables"

You should get something like this:

+----------------------+
| Tables_in_jackrabbit |
+----------------------+
| FS_REPO_FSENTRY      | 
| FS_VERSION_FSENTRY   | 
| FS_WORKSPACE_FSENTRY | 
| PM_VERSION_BINVAL    | 
| PM_VERSION_BUNDLE    | 
| PM_VERSION_NAMES     | 
| PM_VERSION_REFS      | 
| PM_WS_BINVAL         | 
| PM_WS_BUNDLE         | 
| PM_WS_NAMES          | 
| PM_WS_REFS           | 
+----------------------+

and should be able to access the repository in exactly the same way as if it was out of the box (file/derby) based.

Common Problems

org.apache.jackrabbit.rmi.client.RemoteRepositoryException - Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection refused

- Make sure mysql.jar is in right place.

JackrabbitOnTomcat6 (last edited 2011-02-20 10:50:29 by AchimGeisler)