This post gives instructions on the deployment of Jackrabbit JCA Resource Adapter on Glassfish application server. I describe deployment steps in this post, since I wasn't able to find any decent description to do the above and, thus had to figure it out myself. Even though, it isn't a painfull process at all, it took a little bit of time.
I have used the following products:
In order to set up Jackrabbit JCA Resource Adapter on Glassfish you will have to do the following:
- Make JCR API known to Glassfish;
- Install Jackrabbit JCA Resource Adapter on Glassfish;
- Configure Connector Connection Pools on Glassfish;
- Configure Connector Resources on Glassfish;
Make JCR API known to Glassfish
By making JCR API known to Glassfish I mean dropping jcr-2.0.jar library under the <glassfish-install-dir>/glassfish/domains/<your-domain>/lib/ directory. You may need to restart your Glassfish instance.
Install Jackrabbit JCA Resource Adapter on Glassfish
Assuming you have downloaded the required artifacts and started up the Glassfish instance, through the Glassfish web admin UI deploy jackrabbit-jca-2.2.7.rar file using the Applications menu on the Commons Task tree.
Configure Connector Connection Pools on Glassfish
Create new Connector Connection Pools by selecting previously installed jackrabbit-jca-2.2.7.rar in the Resource Adapter field and give name in the Pool Name field, e.g. my-pool.
After clicking Next you will be redirected to the second page. On this page you will have to configure two properties, namely ConfigFile and HomeDir.
- ConfigFile property points to the Jackrabbit repository.xml file, e.g. ~/repo/repository.xml
- HomeDir property points to the location of the Jackrabbit repository on you file system, e.g. ~/repo;
Configure Connector Resources on Glassfish
Finally, create Connector Resource by selecting previously created Connector Connection Pool. You will be able to select you my-pool from the drop down Pool Name menu. Give JNDI Name to you connector resource, e.g. jcr/resource and click OK button. You are done!
Now, you should be able to access JCR repository from you class by injecting as follows:
@Resource ( name = "jcr/repository" )
private Repository repository;
Enjoy!
Hi Janis,
thanks for the post. However, the last hint about placing the jcr-2.0.jar into the lib/ext folder should be step 0, since deploying the jca resource fails otherwise.
Sebastian
Posted by: Prehn81 | October 23, 2011 at 10:33 PM
Hi Sebastian,
Thanks for hint! Even though I have mentioned that at the end of the post, you are right that it should be done before all the other steps.
Janis
Posted by: Janis Kazakovs | October 25, 2011 at 10:46 AM
Placing JAR's in lib/ext is a bit dangerous since is makes it a JDK extension with classes loaded before any GlassFish container implementation class as they are higher up in the classloader delegation chain. I would suggest /lib instead.
Also, 3.1.1 is the latest stable GlassFish version.
Posted by: Alexismp.wordpress.com | October 25, 2011 at 11:21 AM
You are right, lib/ext will make jcr-2.0.jar an installed extension. I have overlooked that. Thanks for feedback.
Looks like this post is getting a perfect shape ;)
Posted by: Janis Kazakovs | October 25, 2011 at 01:27 PM
While configuring connector connection pools on Glassfish I see that there is an additional paramater that can be set namely "RepositoryURI". What is the use this paramater?
Posted by: Mohanstwit | January 20, 2012 at 10:30 PM
Frankly, I do not know much about it. Neither can I find anything on the net. The only think I know is that you should use either repositoryURI or homeDir during connector configuration. Probably, the intention of repositoryURI is the same as of homeDir, but syntax is different, something like this jcr-jackrabbit://jackrabbit.
Sorry, but I can't provide you much info on that.
Posted by: Janis Kazakovs | January 20, 2012 at 11:02 PM
I figured it out. I will explain you more about what I was trying to do. I have CQ5 (Day CMS) installed locally. Day CQ5 comes with CRX(Comercial version of jackrabbit). I was trying to use JCA connector to get the repository instance in my web application running in GlassFish server. I was able to get the repository instance by setting the RepositoryURI to rmi://localhost:1099/crx. I deleted ConfigFile and HomeDir.
Posted by: Mohanstwit | January 21, 2012 at 12:20 AM
Thanks for info. It actually makes sense, since HomeDir and ConfigFile allow you to specify location of the JCR repository local to you Glassfish instance. While this is not always the case, like in your situation.
Posted by: Janis Kazakovs | January 23, 2012 at 11:21 AM
Just followed your instructions again. This is now my reference :-). Maybe you should write "e.g. jcr/repository" instead of "e.g. jcr/resource" in the JNDI section.
Posted by: Prehn81 | September 12, 2012 at 11:58 PM