I am going to use the jackrabbit-webapp-1.5.0.war web application shipped with Jackrabbit 1.5.0 to create a repository inside Glassfish.
In the next tutorial, a simple web application will then be created using Netbeans 6.5 to show how to programatically access the repository (insert and search) via Jndi from a servlet.
Repository set up in Glassfish
First of all, you need to copy the following libraries in the directory for Glassfish V3 Prelude:$GLASSFISH/glassfish/domains/$DOMAINNAME/lib/ext/and for Glassfish V2 in:
$GLASSFISH/domains/$DOMAINNAME/lib/ext/where $GLASSFISH is your glassfish installation directory (i.e. glassfish-v3-prelude) and $DOMAINNAME is your domain (domain1 is the default).
The libraries are:
- commons-collections-3.2.1.jar
- commons-io-1.4.jar
- concurrent.jar
- jackrabbit-api-1.5.0.jar
- jackrabbit-core-1.5.0.jar
- jackrabbit-jcr-commons-1.5.0.jar
- jackrabbit-spi-1.5.0.jar
- jackrabbit-spi-commons-1.5.0.jar
- jackrabbit-text-extractors-1.5.0.jar
- jcr-1.0.jar
- log4j-1.2.15.jar
- lucene-core-2.4.0.jar
- PDFBox-0.7.3.jar
- poi-3.2-FINAL-20081019.jar
- slf4j-api-1.5.6.jar
- slf4j-log4j12-1.5.5.jar
Restart your domain and deploy the jackrabbit-webapp-1.5.0.war you can use the Glassfish admin web tool (usally at http://localhost:4848/) to deploy, I will assume you have deployed with a Context Root set to /jackrabbit with port 8080
We can now test our installation by navigating to http://localhost:8080/jackrabbit/ in your web browser and you should see the page below:

Notice, the web application uses a configuration file bootstrap.properties located in:
$GLASSFISH/glassfish/domains/$DOMAINNAME/config/jackrabbitYou have to modify this file in case you want to change the repository or any setting. If you want to re-deploy starting with a fresh configuration you can delete the folder.
If you choose the default jackrabbit repository it will be created in the same config directories we have just discussed for V3 Prelude:
$GLASSFISH/glassfish/domains/$DOMAINNAME/config/jackrabbit/repositoryfor V2:
$GLASSFISH/domains/$DOMAINNAME/config/jackrabbit/repositoryAlternatevely, you can select any directory your user has read/write permssion, from now onwards I will assume the repository has been created in
$HOME/testrepository
PostgreSQL Configuration
It is now time to configure the repository (which by default use the built-in Derby database) to use instead PostgreSQL.First of all, create a database named testrepository I will create one using PgAdmin with user postgres and template postgres.

Then add the jdbc postgresql driver postgresql-8.3-604.jdbc4.jar again in the directory (V3 Prelude):
$GLASSFISH/glassfish/domains/$DOMAINNAME/lib/ext/while for V2 in:
$GLASSFISH/domains/$DOMAINNAME/lib/ext/PersistenceManager you can use, I prefer the Bundle Database PM.
In order to switch from Derby to PostgresSQL, edit the configuration file
$HOME/testrepository/repository.xmllook for the two entries under Workspace and Versioning:
<PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.DerbyPersistenceManager">and substitute them with:
<param name="url" value="jdbc:derby:${rep.home}/version/db;create=true"/>
<param name="schemaObjectPrefix" value="version_"/>
</PersistenceManager>
<PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager">Few things to be aware of, the schema entry is not really a DB schema but more the "type of DB", on the other hand the schemaObjectPrefix is truly the schema, in this example I am assuming we will use the default public schema. Of course, in the password enter your postgres user password.
<param name="driver" value="org.postgresql.Driver"/>
<param name="url" value="jdbc:postgresql://localhost:5432/testrepository"/>
<param name="schema" value="postgresql"/>
<param name="user" value="postgres"/>
<param name="password" value=""/>
<param name="schemaObjectPrefix" value="public"/>
<param name="externalBLOBs" value="false"/>
</PersistenceManager>
Restart the Glassfish application server and if you use PgAdmin you should see the following tables being created:
0 comments:
Post a Comment