Sunday, December 7, 2008

Jackrabbit Repository Server on JBoss


Updated for jackrabbit 1.5.2



Dependencies:

Jboss 4.2.3

Jackrabbit 1.5.2

Mysql 5.x

jcr-1.0.jar

Maven 2


I'm running JBoss as 4.2.3 on my local PC and I would like to deploy jackrabbit
as a standalone JCR server to create the Repository Server.



In order to have two JBoss servers running on the same box you have to change
the ports of the second server.


Before I updated the ports for the default jboss configuration, I made a copy
of the default directory and called it default-jcr.
I then changed all the ports in default-jcr by appending a 1 in front of the
port name. I used This Document to help identify all the ports.


GOAL: To have a jcr repository server


Get a copy of Jackrabbit. The current version is 1.5.2. Download the source
file and un jar it.



jar -xvf jackrabbit-1.5.2-src.jar
this will create a directory named jackrabbit-1.5.2. I will use to refer to
this directory.

change directory to

modify the following files:

1. /jackrabbit-jcr-rmi/src/main/resources/jackrabbit-rmi-service.xml
and update the RemoteAddress to match the RMI port you changed in the
default-jar jboss configuration.

2. /jackrabbit-jca/deploy/jboss4.x/jcr-ds.xml

jcr/local

jackrabbit-jca-1.5.2.rar

javax.jcr.Repository
/jcr/poc-1.5
/jcr/poc-1.5/repository.xml
true


3. /jackrabbit-jca/target/repository/repository.xml
in this file change the PersistenceManager to use mysql in both places

Repository/PersistenceManager

and

Repository/Versioning/PersistenceManager

In both locations above, be sure that you created an empty database and
created a user in MySQL

build jackrabbit
cd
mvn clean
mvn install

create the directory specified in the jcr-ds.xml above

copy /jackrabbit-jca/target/repository/repository.xml to /jcr/poc-1.5/

copy the following files to the default-jcr configuration

jcr-1.0.jar to default-jcr/lib

mysql-connector-java--bin.jar to default-jcr/lib

jackrabbit-jca-1.5.2.rar to default-jcr/deploy

jackrabbit-jcr-rmi-1.5.0.jar to default-jcr/deploy

jcr-ds.xml to default-jcr/deploy

start Jboss to create the content repository in the directory you specified
above in jcr-ds.xml
run -c default-jcr



Some issues I had in the past


ISSUE


23:26:23,093 WARN [ServiceController] Problem starting service
Jackrabbit.services:RMIServer = JCR RMI Server
javax.naming.CommunicationException: Could not obtain connection to any of
these urls: localhost:1099 and discovery failed with
error: javax.naming.CommunicationException: Receive timed out [Root
exception is java.net.SocketTimeoutException: Receive timed out] [Root
exception is javax.naming.CommunicationException: Failed to connect to
server localhost:1099 [Root exception is
javax.naming.ServiceUnavailableException: Failed to connect to server
localhost:1099 [Root exception is java.net.ConnectException: Connection
refused: connect]]]


SOLUTION


Change C:\jackrabbit-1.4\jackrabbit-jcr-rmi\src\main\resources\jackrabbit-rmi-service.xml
then recompile jackrabbit
cd c:\
cd c:\jackrabbit-1.4
mvn clean
mvn install

replace jackrabbit-jcr-rmi.jar in the deploy-jcr directory with the new file
that was just built.


ISSUE


Issue Using Derby even though I changed the PersistentManager:

here is the portion of the Jboss log that is specific to the start up of
jackrabbit:
00:50:47,906 INFO [RepositoryImpl] Starting repository...
00:50:47,921 INFO [LocalFileSystem] LocalFileSystem initialized at path c:\jackrabbit\poc\repository
00:50:48,046 INFO [NodeTypeRegistry] no custom node type definitions found
00:50:48,046 INFO [LocalFileSystem] LocalFileSystem initialized at path c:\jackrabbit\poc\version
00:50:49,000 INFO [ConnectionRecoveryManager] Database: Apache Derby / 10.2.1.6 - (452058)
00:50:49,000 INFO [ConnectionRecoveryManager] Driver: Apache Derby Embedded JDBC Driver / 10.2.1.6 - (452058)
00:50:50,312 INFO [RepositoryImpl] initializing workspace 'default'...
00:50:50,312 INFO [LocalFileSystem] LocalFileSystem initialized at path c:\jackrabbit\poc\workspaces\default
00:50:50,593 INFO [ConnectionRecoveryManager] Database: MySQL / 5.0.51b-community-nt
00:50:50,593 INFO [ConnectionRecoveryManager] Driver: MySQL-AB JDBC Driver / mysql-connector-java-5.0.8 ( Revision: ${svn.Revision} )
00:50:50,765 INFO [RepositoryImpl] workspace 'default' initialized
00:50:50,953 INFO [LocalFileSystem] LocalFileSystem initialized at path c:\jackrabbit\poc\repository\index
00:50:51,046 INFO [SearchIndex] Index initialized: c:/jackrabbit/poc/repository/index Version: 2
00:50:51,046 INFO [LocalFileSystem] LocalFileSystem initialized at path c:\jackrabbit\poc\workspaces\default\index
00:50:51,046 INFO [SearchIndex] Index initialized: c:\jackrabbit\poc\workspaces\default/index Version: 2
00:50:51,046 INFO [RepositoryImpl] Repository started
00:50:51,046 INFO [jcr/local] Created repository (org.apache.jackrabbit.core.RepositoryImpl@110b205)
00:50:51,046 INFO [jcr/local] Created repository handle (org.apache.jackrabbit.jca.JCARepositoryHandle@10f3801)
00:50:51,062 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=jc
r/local' to JNDI name 'java:jcr/local'
00:50:51,218 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=Jm
sXA' to JNDI name 'java:JmsXA'
00:50:51,343 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=PortalDS'
to JNDI name 'java:PortalDS'
00:50:51,437 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=wikiDatas
ource' to JNDI name 'java:wikiDatasource'


SOLUTION


after correcting the repository.xml file: I have achieved using mysql for both
the repository and workspace.

Repository/PersistenceManager

and

Repository/Versioning/PersistenceManager

the schemaObjectPrefix should be different and also the database if you are
using mysql like I am.

Here is the jboss startup log: i'm using Mysql for both repository and
workspace now
01:04:42,203 INFO [RepositoryImpl] Starting repository...
01:04:42,218 INFO [LocalFileSystem] LocalFileSystem initialized at path c:\jackrabbit\poc\repository
01:04:42,375 INFO [NodeTypeRegistry] no custom node type definitions found
01:04:42,375 INFO [LocalFileSystem] LocalFileSystem initialized at path c:\jackrabbit\poc\version
01:04:42,640 INFO [ConnectionRecoveryManager] Database: MySQL / 5.0.51b-community-nt
01:04:42,640 INFO [ConnectionRecoveryManager] Driver: MySQL-AB JDBC Driver / mysql-connector-java-5.0.8 ( Revision: ${svn.Revision} )
01:04:42,796 INFO [RepositoryImpl] initializing workspace 'default'...
01:04:42,796 INFO [LocalFileSystem] LocalFileSystem initialized at path c:\jackrabbit\poc\workspaces\default
01:04:42,796 INFO [ConnectionRecoveryManager] Database: MySQL / 5.0.51b-community-nt
01:04:42,812 INFO [ConnectionRecoveryManager] Driver: MySQL-AB JDBC Driver / mysql-connector-java-5.0.8 ( Revision: ${svn.Revision} )
01:04:42,937 INFO [RepositoryImpl] workspace 'default' initialized
01:04:43,093 INFO [LocalFileSystem] LocalFileSystem initialized at path c:\jackrabbit\poc\repository\index
01:04:43,218 INFO [SearchIndex] Index initialized: c:/jackrabbit/poc/repository/index Version: 2
01:04:43,218 INFO [LocalFileSystem] LocalFileSystem initialized at path c:\jackrabbit\poc\workspaces\default\index
01:04:43,234 INFO [SearchIndex] Index initialized: c:\jackrabbit\poc\workspaces\default/index Version: 2
01:04:43,234 INFO [RepositoryImpl] Repository started
01:04:43,234 INFO [jcr/local] Created repository (org.apache.jackrabbit.core.RepositoryImpl@1e5ebbf)
01:04:43,234 INFO [jcr/local] Created repository handle (org.apache.jackrabbit.jca.JCARepositoryHandle@8edb84)
01:04:43,234 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=jc
r/local' to JNDI name 'java:jcr/local'
01:04:43,343 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=Jm
sXA' to JNDI name 'java:JmsXA'
01:04:43,406 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=wikiDatas
ource' to JNDI name 'java:wikiDatasource'



ISSUE


Security manager not active


SOLUTION


client.policy & server.policy need to be specifed.
client.policy for the client

server.policy for the JBoss server, set this in the run.bat file


ISSUE


retrieving properties from a RemoteNode class doesn't exist:


SOLUTION


the node Value should be serialized and exist on the server so it
can be unmarshelled before storing to the database. Just include the jar file
containing the extended Value class from when you build the client and
paste it into the JBoss default / lib directory the restart your JBoss server.


ISSUE


Using the JCA connector sessions are not closing properly


SOLUTION


need to add: to the jcr-ds.xml
file (or whatever you called it)


1 comment:

Unknown said...

Hey.. I have a comment...

It is clear that my brother knows a great deal about this programing stuff, as I can't even begin to make sense of what he's writing here. Therefore, it is my MISSION to glean at the very least an iota of understanding of what's going on. As you will find on my blog http://viturvian1.wordpress.com/ I am trying to become more aware of the world in which I live and I have no alternative but to add this to my list of topics that I have to comprehend. Hopefully my brother will assist me with this project as he has so willingly done in the past.