Configuring Hippo 7 for MySQL
A post to the Nabble forum clarified how to configure Hippo 7 to store its content to MySQL.
An aside: setting up your project.
Hippo intends to publish a project creation archetype for Maven (2.0.10) that can be used from a remote repository. For now, the instruction is to checkout and build the Site Toolkit code and install it into your local maven repository. It also installs an archetype of the local kind which you can use to generate a HST-2 project. At the time of writing, this archetype creates a project containing version 2.03.00 of the cms and version 2.03.00-SNAPSHOT of the Hippo Site Toolkit.
Obtain and install the archetype using the following commands:
$ svn co http://svn.hippocms.org/repos/hippo/ecm/site-toolkit/trunk/ hst2 $ cd hst2 $ mvn clean install -DskipTests=true
The hst2 directory can be discarded afterwards.
Next, create an archetype using the command:
$ mvn archetype:generate
Find the correct archetype from the presented list. It will be the one called hst-archetype (Hippo Site Toolkit Archetype). Proceed by entering values for groupId, artifactId, version and package.
Inside your created project directory, you can build and install the site toolkit site, which includes an embedded cms and repository:
$ mvn clean install
From the cms directory, run the cms and afterwards access it on http://localhost:8080/cms/ with the following:
$ mvn jetty:run-war
From the site directory, run the site and afterwards access it on http://localhost:8085/site/preview/home/ with the following:
$ mvn jetty:run
If you rebuild your cms or some other anomaly occurs, your data will be gone. It is a good idea to have a database supporting your cms. This documents contains instructions for setting up MySQL to that end.
First, shut down your running jetty servers, if any.
Configuration
Assumptions:
- Using jetty
Requirements:
- Use MySQL 5+
In a nutshell:
- Add some dependencies to your pom.xml
- Edit jetty-env.xml
- Edit your cms's repository.xml
- Set up a user that can access your tables with the right permissions. javauser/javadude assumed here.
- Create a database. hippocms assumed here.
By default, the persistence manager is configured to be a DerbyPersistenceManager, 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>
...
Other persistence managers are available: H2PersistenceManager, MSSqlPersistenceManager, MySqlPersistenceManager, OraclePersistenceManager. This instruction deals with the MySqlPersistenceManager.
Add these dependencies to your project's cms/pom.xml:
.... <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.0.8</version></dependency> <dependency> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-plus</artifactId> <version>6.1.6</version> </dependency> <dependency> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-naming</artifactId> <version>6.1.6</version> </dependency> ....
If the datasource is going to be called repositoryDS, put the following in jetty-env.xml in your project's cms/src/main/webapp/WEB-INF directory:
<?xml version="1.0"?> <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd"> <Configure class="org.mortbay.jetty.webapp.WebAppContext"> <New id="repositoryDS" class="org.mortbay.jetty.plus.naming.Resource"> <Arg>jdbc/repositoryDS</Arg> <Arg> <New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"> <Set name="Url">jdbc:mysql://localhost:3306/hippocms</Set> <Set name="User">javauser</Set> <Set name="Password">javadude</Set> </New> </Arg> </New> </Configure>
Include the following in your web.xml in your project's cms/src/main/webapp/WEB-INF directory:
...
<resource-ref>
<res-ref-name>jdbc/repositoryDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
...
Create the path classes/org/hippoecm/repository inside your project's cms/src/main/webapp/WEB-INF directory. Create a file there, called repository.xml.
Below is a sample of a repository.xml that configures Hippo to use the MySQL persistence manager:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 1.4//EN" "http://jackrabbit.apache.org/dtd/repository-1.4.dtd"> <Repository> <FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem"> <param name="url" value="java:comp/env/jdbc/repositoryDS"/> <param name="driver" value="javax.naming.InitialContext"/> <param name="schemaObjectPrefix" value="repository_"/> <param name="schema" value="mysql"/> </FileSystem> <Security appName="Jackrabbit"> <AccessManager class="org.hippoecm.repository.security.HippoAccessManager"/> <LoginModule class="org.hippoecm.repository.security.HippoLoginModule"/> </Security> <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/> <Workspace name="${wsp.name}"> <FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem"> <param name="url" value="java:comp/env/jdbc/repositoryDS"/> <param name="driver" value="javax.naming.InitialContext"/> <param name="schemaObjectPrefix" value="${wsp.name}_"/> <param name="schema" value="mysql"/> </FileSystem> <PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.MySqlPersistenceManager"> <param name="driver" value="javax.naming.InitialContext"/> <param name="url" value="java:comp/env/jdbc/repositoryDS"/> <param name="schemaObjectPrefix" value="${wsp.name}_"/> <param name="externalBLOBs" value="true"/> <param name="consistencyCheck" value="false"/> <param name="consistencyFix" value="false"/> <param name="user" value="javauser" /> <param name="password" value="javadude" /> </PersistenceManager> <SearchIndex class="org.hippoecm.repository.FacetedNavigationEngineThirdImpl"> <param name="indexingConfiguration" value="indexing_configuration.xml"/> <param name="indexingConfigurationClass" value="org.hippoecm.repository.query.lucene.ServicingIndexingConfigurationImpl"/> <param name="path" value="${wsp.home}/index"/> <param name="useCompoundFile" value="true"/> <param name="minMergeDocs" value="1000"/> <param name="volatileIdleTime" value="10"/> <param name="maxMergeDocs" value="1000000000"/> <param name="mergeFactor" value="5"/> <param name="maxFieldLength" value="10000"/> <param name="bufferSize" value="1000"/> <param name="cacheSize" value="1000"/> <param name="forceConsistencyCheck" value="false"/> <param name="enableConsistencyCheck" value="false"/> <param name="autoRepair" value="true"/> <param name="analyzer" value="org.apache.lucene.analysis.standard.StandardAnalyzer"/> <param name="queryClass" value="org.apache.jackrabbit.core.query.QueryImpl"/> <param name="respectDocumentOrder" value="false"/> <param name="resultFetchSize" value="2147483647"/> <param name="extractorPoolSize" value="0"/> <param name="extractorTimeout" value="100"/> <param name="extractorBackLogSize" value="100"/> <param name="textFilterClasses" value="org.apache.jackrabbit.extractor.PlainTextExtractor,org.apache.jackrabbit.extractor.MsWordTextExtractor,org.apache.jackrabbit.extractor.MsExcelTextExtractor,org.apache.jackrabbit.extractor.MsPowerPointTextExtractor,org.apache.jackrabbit.extractor.PdfTextExtractor,org.apache.jackrabbit.extractor.OpenOfficeTextExtractor,org.apache.jackrabbit.extractor.RTFTextExtractor,org.apache.jackrabbit.extractor.HTMLTextExtractor,org.apache.jackrabbit.extractor.XMLTextExtractor"/> </SearchIndex> </Workspace> <Versioning rootPath="${rep.home}/version"> <FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem"> <param name="url" value="java:comp/env/jdbc/repositoryDS"/> <param name="driver" value="javax.naming.InitialContext"/> <param name="schemaObjectPrefix" value="version_"/> <param name="schema" value="mysql"/> </FileSystem> <PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.MySqlPersistenceManager"> <param name="driver" value="javax.naming.InitialContext"/> <param name="url" value="java:comp/env/jdbc/repositoryDS"/> <param name="schemaObjectPrefix" value="version_"/> <param name="externalBLOBs" value="true"/> <param name="consistencyCheck" value="false"/> <param name="consistencyFix" value="false"/> <param name="user" value="javauser" /> <param name="password" value="javadude" /> </PersistenceManager> </Versioning> <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex"> <param name="path" value="${rep.home}/repository/index"/> <param name="forceConsistencyCheck" value="false"/> <param name="enableConsistencyCheck" value="false"/> </SearchIndex> <DataStore class="org.apache.jackrabbit.core.data.db.DbDataStore"> <param name="url" value="java:comp/env/jdbc/repositoryDS"/> <param name="driver" value="javax.naming.InitialContext"/> <param name="databaseType" value="mysql"/> <param name="minRecordLength" value="1024"/> <param name="maxConnections" value="5"/> <param name="copyWhenReading" value="true"/> <!-- broken in JR.. param name="tablePrefix" value="repository_"/ --> </DataStore> </Repository>
The database has to be created beforehand and the user must be granted 'create table' privileges.
Example of the database creation:
$ mysql -u root mysql> create database hippocms; mysql> grant all privileges on hippocms.* to javauser@localhost identified by 'javadude';
Do a "mvn clean install" again in your project folder.
Start your jetty servers again as described above.
Tables are created by the repository.
You're good to go!