Dashboard > Community Wiki > ... > Deployment > How to setup JNDIPooledDatabasePersistenceManager
How to setup JNDIPooledDatabasePersistenceManager Log In View a printable version of the current page.

Added by GrĂ©gory Joseph , last edited by Boris Kraft on Jun 23, 2008  (view change)
Labels: 

This is not the default way of using Mysql with Magnolia, i.e this is not using the Mysql persistence manager provided by Jackrabbit, but rather a 3rd party implementation of a persistence manager. Jackrabbit now provides the built-in ability to use datasources, but if you want to completely avoid connection information in your repository configuration files, you'll need at least Jackrabbit 1.4.2 - and the Oracle implementation still has an issue, in that it won't let you set an empty password - see JCR-1562.

Using the JNDIPooledDatabasePersistenceManager

History

This persistence manager is based on the DataSourcePersistenceManager.

It has been modified to depend on the version 1.3 of jackrabbit included in Magnolia 3.5 (and Magnolia 3.0.3+). That version of jackrabbit coupled with the JNDIPooledDatabasePersistenceManager seems to be more stable than the former DataSourcePersistenceManager.

Compatibility issue

As it is based on Jackrabbit 1.3, you can use this persistence manager only with Magnolia 3.5 (and Magnolia 3.0.3+). If you are using anything Magnolia 3.0.3 (3.0, 3.0.1, 3.0.2), please look at DataSourcePersistenceManager.

How it works

This persistance manager will retreive the connection needed (one connection each time the driver is called for a load / store or exists method) from a DataSource (which has been retreive by a JNDI call) definition, and close it at the end of the call.

How to install

  • Unzip magnoliaAuthor.war into a tempory directory
  • Download the jar on http://www.iorga.com/downloads/PooledJNDIDatabasePersistenceManager.jar
  • Place it in the WEB-INF/lib/ directory
  • Create the datasource definition. If you're using Tomcat, edit or create the file <TOMCAT_HOME>/conf/Catalina/localhost/<WEB_APP_NAME>.xml (replacing <TOMCAT_HOME> and <WEB_APP_NAME> with the correct values). Here is an example for Tomcat 5.0.x (be carefull, the structure has changed for 5.5.x), don't forget to replace <USER> <PASSWORD> and <DATABASE> :
    <Context path="/magnoliaAuthor">
    <Resource name="jdbc/magnolia" auth="Container" type="javax.sql.DataSource" />
    
      <ResourceParams name="jdbc/magnolia">
         <parameter>
            <name>factory</name>
            <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
         </parameter>
    
         <parameter>
            <name>driverClassName</name>
            <value>com.mysql.jdbc.Driver</value>
         </parameter>
    
         <parameter>
            <name>validationQuery</name>
            <value>select now();</value>
         </parameter>
    
         <parameter>
            <name>maxWait</name>
            <value>5000</value>
         </parameter>
    
         <parameter>
            <name>maxActive</name>
            <value>4</value>
         </parameter>
    
         <parameter>
            <name>password</name>
            <value><PASSWORD></value>
         </parameter>
    
         <parameter>
            <name>url</name>
            <value>jdbc:mysql:///<DATABASE></value>
         </parameter>
    
         <parameter>
            <name>maxIdle</name>
            <value>2</value>
         </parameter>
    
         <parameter>
            <name>username</name>
            <value><USERNAME></value>
         </parameter>
    
         <parameter>
            <name>removeAbandoned</name>
            <value>true</value>
         </parameter>
    
         <parameter>
            <name>removeAbandonedTimeout</name>
            <value>300</value>
         </parameter>
    
         <parameter>
            <name>logAbandoned</name>
            <value>true</value>
         </parameter>
    
       </ResourceParams>
    </Context>
  • Then edit or create the file WEB-INF/config/repo-conf/jackrabbit-pjdpm-search-author.xml based on WEB-INF/config/repo-conf/jackrabbit-mysql-search.xml. Here is an example :
<Repository>
    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
        <param name="path" value="${rep.home}/repository"/>
    </FileSystem>
    <Security appName="Jackrabbit">
        <AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager"></AccessManager>
        <LoginModule class="org.apache.jackrabbit.core.security.SimpleLoginModule">
            <param name="anonymousId" value="anonymous"/>
        </LoginModule>
    </Security>
    <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
    <Workspace name="default">
        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
            <param name="path" value="${wsp.home}/default" />
        </FileSystem>
        <PersistenceManager class="com.iorga.jackrabbit.core.persistence.db.PooledJNDIDatabasePersistenceManager">
            <param name="dataSourceLocation" value="java:comp/env/jdbc/magnolia"/>
            <param name="schemaObjectPrefix" value="author_${wsp.name}_"/>
            <param name="externalBLOBs" value="false"/>
        </PersistenceManager>
        <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
            <param name="path" value="${wsp.home}/index"/>
            <param name="useCompoundFile" value="true"/>
            <param name="minMergeDocs" value="100"/>
            <param name="volatileIdleTime" value="3"/>
            <param name="maxMergeDocs" value="100000"/>
            <param name="mergeFactor" value="10"/>
            <param name="maxFieldLength" value="10000" />
            <param name="bufferSize" value="10" />
            <param name="cacheSize" value="1000" />
            <param name="forceConsistencyCheck" 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="true" />
            <param name="resultFetchSize" value="2147483647" />
            <param name="extractorPoolSize" value="3" />
            <param name="extractorTimeout" value="100" />
            <param name="extractorBackLogSize" value="100" />
            <param name="textFilterClasses"
              value="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.local.LocalFileSystem">
            <param name="path" value="${rep.home}/workspaces/version"/>
        </FileSystem>
        <PersistenceManager class="com.iorga.jackrabbit.core.persistence.db.PooledJNDIDatabasePersistenceManager">
            <param name="dataSourceLocation" value="java:comp/env/jdbc/magnolia"/>
            <param name="schemaObjectPrefix" value="author_version_"/>
            <param name="externalBLOBs" value="false"/>
        </PersistenceManager>
    </Versioning>
</Repository>
  • Edit the file WEB-INF/config/defautl/magnolia.properties and change the value magnolia.repositories.jackrabbit.config to : magnolia.repositories.jackrabbit.config=WEB-INF/config/repo-conf/jackrabbit-pjdpm-search-author.xml
  • Delete the bundled datas provided with the (not so good) Derby PersistenceManager : delete the folder repositories
  • Make sure you have the mysql jdbc connector from http://dev.mysql.com/downloads/connector/j/5.1.html (put it in tomcat/common/lib).
  • Rezip magnoliaAuthor.war
  • Proceed through all the previous steps replacing "author" by "public" and "Author" by "Public" anywhere it's possible in order to patch also magnoliaPublic.war

FAQ

Please feel free to add your answered questions here.

In its previous incarnation on JspWiki, this page was last edited on Oct 20, 2007 1:20:07 AM by Magnolia
Other known authors include :

  • AnthonyOgier
  • AnthonyOgier
  • BorisKraft
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