Dashboard > Community Wiki Archive > Home > Using Mysql with Magnolia 2.1.5
Using Mysql with Magnolia 2.1.5 Log In View a printable version of the current page.

Added by GrĂ©gory Joseph , last edited by GrĂ©gory Joseph on Jul 15, 2008  (view change)
Labels: 

There are a bunch of pages related to Mysql. If someone wants to volunteer and merge them, that'd be much appreciated.

MySQL Persistence (Community Wiki)
Labels: v3_5, jackrabbit, mysql, installation, config, persistence
Setting up a MySQL repository (Community Wiki Archive)
Labels: outdated, mysql, persistence, deployment
Using Mysql with Magnolia 2.1.5 (Community Wiki Archive)
Labels: v2_1, mysql, deployment, persistence

There's one of these articles in the 3.0 section and I've seen people try to adapt it to the 2.1.x branch. Here's a quick primer for moving the repositories in 2.1.x from derby (the default) to MySQL.

The first thing you need to understand is the 2.1.x branch uses 4 separate repositories – website, config, users, and userroles. This was a great solution in the early days of jackrabbit when the JCR 170 spec was still being written. Thankfully, the spec has matured and Magnolia version 3.0 has consolidated down to just one repository and 4 workspaces.

On to the instructions:

1. If you haven't already done it, download the latest Magnolia 2.1.x release (2.1.5 at the time this was written)

2. Explode the .war files for magnoliaAuthor and magnoliaPublic into different places. The .war format itself is really just a zip archive so any unzip program should be able to handle this.

3. Download the latest general release version of MySQL Connector-J from MySQL's website. At the time of writing, it was 5.0.3.

4. Place the Mysql driver .jar file in the WEB-INF/lib directory of each webapp – magnoliaPublic and magnoliaAuthor.

5. In both magnoliaAuthor and mangoliaPublic folders, go into WEB-INF/config/repositories/repo-config and perform steps 6-12

6. copy magnola-derby-search.xml to magnolia-mysql-search.xml and magnolia-derby-nosearch.xml to magnolia-mysql-nosearch.xml

7. Edit magnolia-mysql-search.xml and magnola-mysql-nosearch.xml to replace:

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

with:

<PersistenceManager class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
        <param name="driver" value="com.mysql.jdbc.Driver"/>
        <param name="url" value="jdbc:mysql://localhost:3306/magnoliaAuthorDb?autoReconnect=true"/>
        <param name="schema" value="mysql"/>
        <param name="user" value="root"/>
        <param name="password" value="wsp"/>
        <param name="schemaObjectPrefix" value="${wsp.name}_"/>
        <param name="externalBLOBs" value="false"/>
</PersistenceManager>

8. Modify the parameters as necessary for your environment. You'll want magnoliaAuthor and magnoliaPublic on separate databases in your MySQL server, so be sure to modify the url attribute above appropriately.

9. Make a similar change in the PersistenceManager element of the Versioning section.

10 Make one dupicate of these files for each repository in the system – website, config, users, userroles, naming them jackrabbit-mysql-website-search.xml, jackrabbit-mysql-website-nosearch.xml, etc., ...

11. Re-edit each of the 8 new files, changing just the schemaObjectPrefix of the PersistenceManager elements to a format similar to repname_${wsp.name}_ for the workspace and repname_version_ for the versioning sections replacing repname with the name of the repository. For example, if you are working on jackrabbit-mysql-website-search.xml, the workspace schemaObjectPrefix would be website_${wsp.name}. schemaObjectPrefix for versioning would be website_version.

Wodering why so many repo-conf files? As I said, magnolia uses 4 repositories and Jackrabbit only expects any given appliction to use just one repository. Otherwise you would have a variable rep.name to stick in there and only need two files (search and nosearch) with schemaObjectPrefixes of ${rep.name}${wsp.name} and ${rep.name}version.

Magnolia only really needs 4 of these repo-conf files – one for each repository. You could just do jackrabbit-mysql-website-search.xml and the remaining 3 files as jackrabbit-mysql-(config|users|userroles)-nosearch.xml, eliminating 4 files that won't be used.

We are still doing at least one per repository to eliminate table naming collisions. The schemaObjectPrefix controls the name of the tables in the database.

12. Go into WEB-INF/conf/default and edit repositories.xml changing where you see WEB-INF/config/repo-conf/jackrabbit-derby-(no)search.xml to WEB-INF/config/repo-conf/jackrabbit-mysql-(repName)-(no)search.xml. (repName) should be replaced with the name of the repository.

13. Copy your updated magnoliaAuthor and magnoliaPublic folders to the webapps directory of tomcat and start it up. You can also re pack them into .war archives if you like.

That's it, enjoy! All done and bootstrapped, you'll end up with 32 tables in each database, 8 for each repository.

Contributed by David Smith (dns4@cornell.edu).

In its previous incarnation on JspWiki, this page was last edited on Feb 9, 2007 11:01:16 AM by DSmithAtCornell

Powered by a free Atlassian Confluence Open Source Project License granted to Magnolia International. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators