Say hello to Jackrabbit

Source code available @
svn checkout jackrabbittutorial

I believe in show and tell. So here is an introductory post that shows you how simple it is to start using a powerful content management system called Jackrabbit using a JCP standardized API called JCR API. It is setup as a maven 2 project and I will be progressively building on this project to take you through steps to build powerful software systems that uses JCR API and Jackrabbit implementation in particular to manage content. Here the Key word is content and in my definition content covers the complex world of applications that require to manage relational data that can traditionally be stored in relational databases and binary content such as video, pictures and audio.

package org.boni.jrtutorial.util;

import static org.junit.Assert.assertNotNull;

import javax.jcr.Node;
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;

import org.apache.jackrabbit.core.TransientRepository;
import org.junit.Test;
public class JackrabbitConnectionTest {
	public void testCanConnectToJackrabbit(){
		try {
			//Creates a transient repository at the default 
			Repository repository = new TransientRepository(
			Session aSession = repository.login(
									new SimpleCredentials(
			Node rootNode =  aSession.getRootNode();
			Node aNode = rootNode.addNode("firstChildnode");
		} catch (Exception e) {
			throw new RuntimeException(e);

<project 	xmlns="" 



The simple testcase above creates a content repository under your target/repository folder. It creates a ‘Node’ and then removes it. While we have not added any meaningful data through this code please be rest assured that you can store giga bytes of data efficiently to that single node. You could add files, attributes or more nodes of some other kind. You have the flexibility of choosing to store data on a single file system or multiple file systems depending upon your requirements. Furthermore you can search the data very easily and efficiently using a pluggable search engine. For most of us the default search engine , Apache Lucene is powerful enough and for the greedy there definitely is a way to choose your pick. The data elements can be connected and referential integrity could be enforced. These is a powerful caching system purrring silently under the hood making your fetches as efficient as it should be. The icing on the cake is that there is so little to learn to start using this baby and there already is a powerful ORM layer. Talking about ORM layers there are Options too. I mean to cover all these and more in the forthcoming posts. So stay tuned. Ciao!1. 1.

One Thought on “Jackrabbit – Introduction [Part 1]

  1. murali on May 15, 2013 at 9:27 am said:

    good morning BONI ….. this is murali..
    i need a help …. i.e i need to create a repository or i need to create a new work space ….through programatically…
    i done the work space creating but i unable to access the created workspaces.. if u know just help me…

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation