Posted by Jukka Zitting JUN 04, 2010
Posted in crx, crx gems, jackrabbit, jcr and jsr-283 Comments 6
The J2EE Connector Architecture (JCA) is a mechanism by which applications can access all kinds of information systems in a controlled and coordinated manner. The JCA support included in application servers like Weblogic and JBoss takes care of managing things like connections, transactions and connection security on behalf of a client application. To do this, the application server leverages a JCA connector for the information system being accessed.
JCA is quite useful in many environments with complex integration requirements, so thanks to a community contribution, the Apache Jackrabbit project has been shipping a JCA connector since the 1.0 release. However, the Jackrabbit JCA connector was originally designed to run the Jackrabbit repository in embedded mode within the connector itself, only providing standard JCR API access to client applications. This made the connector design unsuitable for repositories like CRX that include a full suite of web-based management and editing tools that need access to repository internals. We worked around this issue with custom solutions for some CRX 1.x customers, but an improved JCA connector design was clearly needed.
Instead of implementing something for just CRX, we wanted to make a generic JCA connector for all JCR implementations and release it as open source. This way we'll return the favor to the community that contributed the original JCA connector code and will benefit from any improvements and fixes by the external contributors.
To improve the connector design, we turned to the RepositoryFactory interface introduced in JCR 2.0 and the Repository URI work we had done earlier. With these tools we could turn the existing Jackrabbit JCA connector from a Jackrabbit-specific tool to one that supports all JCR 2.0 implementations. This work was tracked in JCR-2555 and released as a part of Jackrabbit 2.1.0. You can find the resulting JCA resource archive (rar) file on the Jackrabbit download page.
To use the JCA connector with CRX on for example the JBoss application server, you first need install the CRX webapp following the normal installation documentation. Then deploy the Jackrabbit JCA rar file without modifications. Finally, as the last step you only need to connect these two resources together by deploying a connection factory descriptor like the one shown below:
<connection-factories>
<tx-connection-factory>
<jndi-name>jcr/crx</jndi-name>
<xa-transaction/>
<rar-name>jackrabbit-jca-2.1.0.rar</rar-name>
<connection-definition>
javax.jcr.Repository
</connection-definition>
<config-property name="repositoryURI"
type="java.lang.String">
jndi://?org.apache.jackrabbit.repository.jndi.name=crx
&java.naming.factory.initial
=com.day.util.jndi.provider.MemoryInitialContextFactory
&java.naming.provider.url
=http://jcr.day.com
</config-property>
<config-property name="bindSessionToTransaction"
type="java.lang.Boolean">true</config-property>
</tx-connection-factory>
</connection-factories>
NOTE: The repositoryURI configuration property has been split to multiple lines for display. It needs to be all in one one in an actual descriptor file.
Set the jndi-name to the path under which you want the JCA-managed Repository instance to be available in the default JNDI context of the application server. Note also that you need to adjust the rar-name setting if you've deployed a different version of the Jackrabbit JCA rar file.
The diagram below illustrates how these different components work together:

When you need to replicate this setup over multiple application servers, you can even package these components together with your application inside an enterprise archive (ear) for simple deployment of your entire setup. But that's a topic for another post...

The capability to expose a Java content repository through CMIS has been around for a while (see for example Day's