0
votes

I've been successfully using Apache Jackrabbit 2.4.3 and now 2.6.0 (standalone server in both cases) using the default configuration, so the repository is stored on the filesystem.

How can I make it connect to a MySQL back end instead? I don't need to worry about migration, just set it up as a fresh install.

After trying the steps below, Jackrabbit fails to start correctly or populate the DATASTORE table in the database, and I find this error in the logs:

ERROR [main] RepositoryImpl.java:366           failed to start Repository: Cannot instantiate persistence manager org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager
    javax.jcr.RepositoryException: Cannot instantiate persistence manager org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager
    [... oodles of backtrace cut ...]

[edit: here's the full backtrace]

2013-03-04 10:59:27.526 WARN  [main] Slf4jLog.java:89                  unavailable
javax.jcr.RepositoryException: Cannot instantiate persistence manager org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager
        at org.apache.jackrabbit.core.RepositoryImpl.createPersistenceManager(RepositoryImpl.java:1353) ~[jackrabbit-standalone-2.6.0.jar:na]
        at org.apache.jackrabbit.core.RepositoryImpl.createVersionManager(RepositoryImpl.java:486) ~[jackrabbit-standalone-2.6.0.jar:na]
        at org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:311) ~[jackrabbit-standalone-2.6.0.jar:na]
        at org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:589) ~[jackrabbit-standalone-2.6.0.jar:na]
        at org.apache.jackrabbit.core.RepositoryContext.create(RepositoryContext.java:149) ~[jackrabbit-standalone-2.6.0.jar:na]
        at org.apache.jackrabbit.servlet.jackrabbit.JackrabbitRepositoryServlet.init(JackrabbitRepositoryServlet.java:109) ~[jackrabbit-standalone-2.6.0.jar:na]
        at javax.servlet.GenericServlet.init(GenericServlet.java:241) ~[jackrabbit-standalone-2.6.0.jar:na]
        at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440) [jackrabbit-standalone-2.6.0.jar:na]
        at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:263) [jackrabbit-standalone-2.6.0.jar:na]
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) [jackrabbit-standalone-2.6.0.jar:na]
        at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685) [jackrabbit-standalone-2.6.0.jar:na]
        at org.mortbay.jetty.servlet.Context.startContext(Context.java:140) [jackrabbit-standalone-2.6.0.jar:na]
        at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250) [jackrabbit-standalone-2.6.0.jar:na]
        at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) [jackrabbit-standalone-2.6.0.jar:na]
        at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467) [jackrabbit-standalone-2.6.0.jar:na]
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) [jackrabbit-standalone-2.6.0.jar:na]
        at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) [jackrabbit-standalone-2.6.0.jar:na]
        at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115) [jackrabbit-standalone-2.6.0.jar:na]
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) [jackrabbit-standalone-2.6.0.jar:na]
        at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) [jackrabbit-standalone-2.6.0.jar:na]
        at org.mortbay.jetty.Server.doStart(Server.java:224) [jackrabbit-standalone-2.6.0.jar:na]
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) [jackrabbit-standalone-2.6.0.jar:na]
        at org.apache.jackrabbit.standalone.Main.run(Main.java:173) [jackrabbit-standalone-2.6.0.jar:na]
        at org.apache.jackrabbit.standalone.Main.main(Main.java:60) [jackrabbit-standalone-2.6.0.jar:na]
Caused by: javax.jcr.RepositoryException: Could not load JDBC driver class org.gjt.mm.mysql.Driver
        at org.apache.jackrabbit.core.util.db.ConnectionFactory.getDriverClass(ConnectionFactory.java:265) ~[jackrabbit-standalone-2.6.0.jar:na]
        at org.apache.jackrabbit.core.util.db.ConnectionFactory.createDataSource(ConnectionFactory.java:233) ~[jackrabbit-standalone-2.6.0.jar:na]
        at org.apache.jackrabbit.core.util.db.ConnectionFactory.getDataSource(ConnectionFactory.java:169) ~[jackrabbit-standalone-2.6.0.jar:na]
        at org.apache.jackrabbit.core.persistence.pool.BundleDbPersistenceManager.getDataSource(BundleDbPersistenceManager.java:569) ~[jackrabbit-standalone-2.6.0.jar:na]
        at org.apache.jackrabbit.core.persistence.pool.BundleDbPersistenceManager.init(BundleDbPersistenceManager.java:537) ~[jackrabbit-standalone-2.6.0.jar:na]
        at org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager.init(MySqlPersistenceManager.java:51) ~[jackrabbit-standalone-2.6.0.jar:na]
        at org.apache.jackrabbit.core.RepositoryImpl.createPersistenceManager(RepositoryImpl.java:1349) ~[jackrabbit-standalone-2.6.0.jar:na]
        ... 23 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217) ~[na:1.6.0_27]
        at java.security.AccessController.doPrivileged(Native Method) ~[na:1.6.0_27]
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205) ~[na:1.6.0_27]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:321) ~[na:1.6.0_27]
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) ~[na:1.6.0_27]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:266) ~[na:1.6.0_27]
        at java.lang.Class.forName0(Native Method) ~[na:1.6.0_27]
        at java.lang.Class.forName(Class.java:188) ~[na:1.6.0_27]
        at org.apache.jackrabbit.core.util.db.ConnectionFactory.getDriverClass(ConnectionFactory.java:260) ~[jackrabbit-standalone-2.6.0.jar:na]
        ... 29 common frames omitted

What I've done so far:

I've created the Jackrabbit database/user, which I can connect to no problem:

mysql -D jackrabbit -u jackrabbit -h localhost -pjackrabbit

I started with a clean slate (empty /var/jackrabbit directory), except the configuration file comes from here: https://raw.github.com/wiki/jackalope/jackalope/files/repository.xml

Here's the startup script I'm using: https://github.com/sixty-nine/Jackrabbit-startup-script

And here's the java process that runs:

java -XX:MaxPermSize=128m -Xmx512M -Xms128M -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1111 -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=/opt/jackrabbit/startup/jmx.user -Dcom.sun.management.jmxremote.access.file=/opt/jackrabbit/startup/jmx.role -jar /opt/jackrabbit/jackrabbit-standalone-2.6.0.jar -h 127.0.0.1 -p 8080

I don't think I get far enough for it to matter, but I'm using MySQL 5.5.28-1.

I'm having the above problem with both 2.4.3 and 2.6.0.

Also:

java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (6b24-1.11.5-1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

Plus I subsequently installed the MySQL JDBC library on Debian:

apt-get install libmysql-java
4
Coud you append [... oodles of backtrace cut ...]?Thomas Mueller
Just done, thanks for looking. It seems to be having trouble finding the org.gjt.mm.mysql.Driver (or com.mysql.jdbc.Driver which I've also tried), despite the fact that I can see those classes in the jar file, and have tried the classpath option -cp /usr/share/java/mysql-connector-java-5.1.16.jarfazy

4 Answers

1
votes

The MySqlPersistenceManager tries to load the driver class org.gjt.mm.mysql.Driver, which is very old. Try using a more recent driver class, the class com.mysql.jdbc.Driver instead. To do that, you would need to configure the persistence manager in the repository.xml and all workspace.xml files as follows:

<PersistenceManager ...>
    ...
    <param name="driver" value="com.mysql.jdbc.Driver"/>
</PersistenceManager>
1
votes

In order to load the MySQL driver with Apache Jackrabbit-standalone. You will need to update the jackrabbit-stabndalone-x.x.x.jar in MANIFEST.MF.

Simply add a Class-Path statement to the bottom of the file such as:

Class-Path: lib/mysql-connector-java-5.1.25-bin.jar

I had the same problem as you and this was the only way I could get the MySQL driver class recognized.

0
votes

Answering my own question, although it doesn't directly answer it:

Instead of trying to use the jackrabbit-standalone version, I've successfully got it running under Tomcat by following the instructions here:

https://github.com/jackalope/jackalope/wiki/Running-jackrabbit-in-tomcat-with-mysql

This gives me what I need; a working Jackrabbit instance that connects to a MySQL data store. Although this doesn't help anyone who comes across this and specifically needs to use Jackrabbit standalone, I would say that setting it up under Tomcat proved much easier for me, so is worth considering.

0
votes

Please do the following activities.

  1. Un-jar the standalone server jar (in my case it is : jackrabbit-standalone-2.8.3). You will see many folders. among them you will find two folder. 1.com 2. org.

  2. Un-jar mysql-connector-java-5.1.30-bin. again you will find above mentioned two folders. go inside both the folders and copy the git(org) and mysql(com)

  3. Paste inside the step 1's folder respectively. and restart the standalone server.

Regards, Nitesh