incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Sling Website > Jackrabbit Persistence
Date Mon, 14 Jun 2010 12:58:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=SLINGxSITE&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/SLINGxSITE/Jackrabbit+Persistence">Jackrabbit
Persistence</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~fmeschbe">Felix
Meschberger</a>
    </h4>
        <br/>
                         <h4>Changes (5)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h2. Replace Derby in a running Sling
Instance <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >To replace Derby in a running
Sling instance just uninstall the Derby bundle and install the JDBC driver bundle through
the Web Console (at <span class="diff-changed-words">{{/system/console}}<span class="diff-added-chars"style="background-color:
#dfd;">)</span>.</span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h2. Reconfiguring Jackrabbit <br>
<br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Two
options: <br>  * Reconfigure after first startup <br>  * Reconfigure build <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">To
actually use a persistence manager other than the default (Derby) persistence manager, you
have to configure Jackrabbit to use it. There are two options: You can modify the build or
you can create a {{repository.xml}} file in the {{sling/jackrabbit}} folder before starting
Sling for the first time. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h3.
Prepare repository.xml File <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">To
prepare a repository.xml file before first startup, use the {{[repository.xml|http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-server/src/main/resources/repository.xml]}}
as a template and modify it by replacing the {{&lt;PersistenceManager&gt;}} elements
to refer to the selected persistence manager. <br> <br>For example to use PostgreSQL
instead of Derby modify the {{&lt;PersistenceManager&gt;}} elements as follows: <br>
<br>{code} <br>&lt;Repository&gt; <br>    ... <br>    &lt;Workspace
name=&quot;${wsp.name}&quot;&gt; <br>        ... <br>        &lt;PersistenceManager
class=&quot;org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager&quot;&gt;
<br>            &lt;param name=&quot;driver&quot; value=&quot;org.postgresql.Driver&quot;/&gt;
<br>            &lt;param name=&quot;url&quot; value=&quot;jdbc:postgresql://localhost:5432/YOUR_DB_NAME_HERE&quot;/&gt;
<br>            &lt;param name=&quot;schema&quot; value=&quot;postgresql&quot;/&gt;
<br>            &lt;param name=&quot;user&quot; value=&quot;YOUR_USER_HERE&quot;/&gt;
<br>            &lt;param name=&quot;password&quot; value=&quot;YOUR_PASSWORD_HERE&quot;/&gt;
<br>            &lt;param name=&quot;schemaObjectPrefix&quot; value=&quot;jcr_${wsp.name}_&quot;/&gt;
<br>            &lt;param name=&quot;externalBLOBs&quot; value=&quot;false&quot;/&gt;
<br>        &lt;/PersistenceManager&gt; <br>        ... <br>   
&lt;/Workspace&gt; <br> <br>    &lt;Versioning rootPath=&quot;${rep.home}/version&quot;&gt;
<br>        ... <br>        &lt;PersistenceManager class=&quot;org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager&quot;&gt;
<br>            &lt;param name=&quot;driver&quot; value=&quot;org.postgresql.Driver&quot;/&gt;
<br>            &lt;param name=&quot;url&quot; value=&quot;jdbc:postgresql://localhost:5432/YOUR_DB_NAME_HERE&quot;/&gt;
<br>            &lt;param name=&quot;schema&quot; value=&quot;postgresql&quot;/&gt;
<br>            &lt;param name=&quot;user&quot; value=&quot;YOUR_USER_HERE&quot;/&gt;
<br>            &lt;param name=&quot;password&quot; value=&quot;YOUR_PASSWORD_HERE&quot;/&gt;
<br>            &lt;param name=&quot;schemaObjectPrefix&quot; value=&quot;version_&quot;/&gt;
<br>            &lt;param name=&quot;externalBLOBs&quot; value=&quot;false&quot;/&gt;
<br>        &lt;/PersistenceManager&gt; <br>    &lt;/Versioning&gt;
<br>    ... <br>&lt;/Repository&gt; <br>{code} <br> <br>Modify
the {{url}}, {{user}}, and {{password}} parameters to match your database setup. <br>
<br> <br>h3. Modify the Build <br> <br>To modify the build apply above
changes directly to the {{src/main/resources/repository.xml}} file in the Embedded Jackrabbit
Server bundle source. <br> <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h2. Credits <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="JackrabbitPersistence-JackrabbitPersistence"></a>Jackrabbit
Persistence</h1>

<p>Out-of-the-box the embedded Jackrabbit repository used by Sling (the Embedded Jackrabbit
Repository bundle) uses Derby to persist the JCR nodes and properties. For some applications
or environments it may be required or required to replace Derby with another backing store
such as PostgreSQL or Oracle.</p>

<p>This page is based on the journey of Tony Giaccone to get Sling running with a PostgreSQL
based Jackrabbit instance.</p>


<h2><a name="JackrabbitPersistence-ManagementSummary"></a>Management Summary</h2>

<p>To replace Derby as the persistence manager for Jackrabbit the following steps are
required:</p>

<ol>
	<li>Provide a JDBC driver for your database as an OSGi bundle</li>
	<li>Reconfigure Jackrabbit to use your database</li>
	<li>(Re-) Start the Embedded Jackrabbit bundle</li>
</ol>


<p>When you are not using the Derby persistence manager, you may safely remove the Derby
bundle from your Sling instance.</p>


<h2><a name="JackrabbitPersistence-JDBCDriver"></a>JDBC Driver</h2>

<p>The hardest thing to do is probably getting the JDBC driver for your database. One
option is to look at the bundles provided by Spring Source in their repository at <a href="http://www.springsource.com/repository/"
class="external-link" rel="nofollow">http://www.springsource.com/repository/</a>.</p>

<p>Another option is to create the bundle on your own using Peter Kriens' <a href="http://www.aqute.biz/Code/Bnd"
class="external-link" rel="nofollow">BND Tool</a>:</p>

<ol>
	<li>Get the JDBC driver for your database from the driver provider</li>
	<li>Wrap the JDBC driver library into an OSGi bundle:
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
# Example <span class="code-keyword">for</span> PostgreSQL JDBC 3 driver 8.4-701
$ java -jar bnd.jar wrap postgresql-8.4-701.jdbc3.jar
$ mv postgresql-8.4-701.jdbc3.bar postgresql-8.4-701.jdbc3-bnd.jar
</pre>
</div></div></li>
	<li>Deploy the driver to your local Maven 2 Repository (Required if adding the JDBC
driver to the Sling build)
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
$ mvn install:install-file -DgroupId=postgresql -DartifactId=postgresql -Dversion=8.4.701.jdbc3
\
		-Dpackaging=jar -Dfile=postgresql-8.4-701.jdbc3-bnd.jar 
</pre>
</div></div></li>
</ol>


<p>Tony reports no success with the Spring Source bundle, whily the BND approach worked
for the PostgreSQL JDBC driver.</p>


<h2><a name="JackrabbitPersistence-ReplaceDerbyinarunningSlingInstance"></a>Replace
Derby in a running Sling Instance</h2>

<p>To replace Derby in a running Sling instance just uninstall the Derby bundle and
install the JDBC driver bundle through the Web Console (at <tt>/system/console</tt>).</p>


<h2><a name="JackrabbitPersistence-ReplaceDerbyintheSlingBuild"></a>Replace
Derby in the Sling Build</h2>

<p>To replace Derby (included with Sling by default) with the new JDBC driver, the bundle
list file <tt>src/main/bundles/list.xml</tt> of the Sling Launchpad Builder project
can be modified.</p>

<p>Look for the Derby database section:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;bundle&gt;
    &lt;groupId&gt;org.apache.derby&lt;/groupId&gt;
    &lt;artifactId&gt;derby&lt;/artifactId&gt;
    &lt;version&gt;10.5.3.0_1&lt;/version&gt;
&lt;/bundle&gt;
</pre>
</div></div>

<p>and replace this section by the Maven 2 reference to your JDBC driver.</p>

<p>For example, for the PostgreSQL JDBC driver bundle prepared in the prepared in the
previous step replace the Derby reference with this:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;bundle&gt;
    &lt;groupId&gt;postgresql&lt;/groupId&gt;
    &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
    &lt;version&gt;8.4.701.jdbc3&lt;/version&gt;
&lt;/bundle&gt;
</pre>
</div></div>


<h2><a name="JackrabbitPersistence-ReconfiguringJackrabbit"></a>Reconfiguring
Jackrabbit</h2>

<p>To actually use a persistence manager other than the default (Derby) persistence
manager, you have to configure Jackrabbit to use it. There are two options: You can modify
the build or you can create a <tt>repository.xml</tt> file in the <tt>sling/jackrabbit</tt>
folder before starting Sling for the first time.</p>

<h3><a name="JackrabbitPersistence-Preparerepository.xmlFile"></a>Prepare
repository.xml File</h3>

<p>To prepare a repository.xml file before first startup, use the <tt><a href="http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-server/src/main/resources/repository.xml"
class="external-link" rel="nofollow">repository.xml</a></tt> as a template
and modify it by replacing the <tt>&lt;PersistenceManager&gt;</tt> elements
to refer to the selected persistence manager.</p>

<p>For example to use PostgreSQL instead of Derby modify the <tt>&lt;PersistenceManager&gt;</tt>
elements as follows:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;Repository&gt;
    ...
    &lt;Workspace name=<span class="code-quote">"${wsp.name}"</span>&gt;
        ...
        &lt;PersistenceManager class=<span class="code-quote">"org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager"</span>&gt;
            &lt;param name=<span class="code-quote">"driver"</span> value=<span
class="code-quote">"org.postgresql.Driver"</span>/&gt;
            &lt;param name=<span class="code-quote">"url"</span> value=<span
class="code-quote">"jdbc:postgresql:<span class="code-comment">//localhost:5432/YOUR_DB_NAME_HERE"</span>/&gt;
</span>            &lt;param name=<span class="code-quote">"schema"</span>
value=<span class="code-quote">"postgresql"</span>/&gt;
            &lt;param name=<span class="code-quote">"user"</span> value=<span
class="code-quote">"YOUR_USER_HERE"</span>/&gt;
            &lt;param name=<span class="code-quote">"password"</span> value=<span
class="code-quote">"YOUR_PASSWORD_HERE"</span>/&gt;
            &lt;param name=<span class="code-quote">"schemaObjectPrefix"</span>
value=<span class="code-quote">"jcr_${wsp.name}_"</span>/&gt;
            &lt;param name=<span class="code-quote">"externalBLOBs"</span>
value=<span class="code-quote">"<span class="code-keyword">false</span>"</span>/&gt;
        &lt;/PersistenceManager&gt;
        ...
    &lt;/Workspace&gt;

    &lt;Versioning rootPath=<span class="code-quote">"${rep.home}/version"</span>&gt;
        ...
        &lt;PersistenceManager class=<span class="code-quote">"org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager"</span>&gt;
            &lt;param name=<span class="code-quote">"driver"</span> value=<span
class="code-quote">"org.postgresql.Driver"</span>/&gt;
            &lt;param name=<span class="code-quote">"url"</span> value=<span
class="code-quote">"jdbc:postgresql:<span class="code-comment">//localhost:5432/YOUR_DB_NAME_HERE"</span>/&gt;
</span>            &lt;param name=<span class="code-quote">"schema"</span>
value=<span class="code-quote">"postgresql"</span>/&gt;
            &lt;param name=<span class="code-quote">"user"</span> value=<span
class="code-quote">"YOUR_USER_HERE"</span>/&gt;
            &lt;param name=<span class="code-quote">"password"</span> value=<span
class="code-quote">"YOUR_PASSWORD_HERE"</span>/&gt;
            &lt;param name=<span class="code-quote">"schemaObjectPrefix"</span>
value=<span class="code-quote">"version_"</span>/&gt;
            &lt;param name=<span class="code-quote">"externalBLOBs"</span>
value=<span class="code-quote">"<span class="code-keyword">false</span>"</span>/&gt;
        &lt;/PersistenceManager&gt;
    &lt;/Versioning&gt;
    ...
&lt;/Repository&gt;
</pre>
</div></div>

<p>Modify the <tt>url</tt>, <tt>user</tt>, and <tt>password</tt>
parameters to match your database setup.</p>


<h3><a name="JackrabbitPersistence-ModifytheBuild"></a>Modify the Build</h3>

<p>To modify the build apply above changes directly to the <tt>src/main/resources/repository.xml</tt>
file in the Embedded Jackrabbit Server bundle source.</p>


<h2><a name="JackrabbitPersistence-Credits"></a>Credits</h2>

<p>This description is based on Tony Giaccone's description <a href="http://markmail.org/message/wlbfrukmjjsl33hh"
class="external-link" rel="nofollow">Swapping Postgres for Derby</a> sent to the
Sling Users mailing list.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/SLINGxSITE/Jackrabbit+Persistence">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=22315341&revisedVersion=2&originalVersion=1">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/SLINGxSITE/Jackrabbit+Persistence?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message