jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From S├ębastien Launay <sebastienlau...@gmail.com>
Subject Re: Jackrabbit model 2 implementation with spring
Date Tue, 29 Dec 2009 14:52:53 GMT
Hi Sajith,

2009/12/29 Sajith Puravankara <sajith.pc@thinkcoretech.com>:
> Hi,
> I am new to jackrabbit. I want to setup a content repository for my spring
> web application.
> Now it is throwing ClassCastException: cannot cast from BindableRepository
> to javax.jcr.Repository

The jackrabbit-standalone jar is designed to be used in standalone mode,
directly with java -jar and not in a container / servlet engine environment.

Indeed the standalone jar embed all dependencies and in your case the
JCR 1.0 classes (e.g. javax.jcr.Repository)  will be both in jcr-1.0.jar and
in jackrabbit-standalone-1.5.7.jar hence the ClassCastException
(because the same class is loaded by two different class loader).

Removing the jcr-1.0.jar may fix your issue but using the standalone jar
is not recommended here and you will certainly have more ClassCastException
later if you use Lucene or commons-collections or any other JR dependencies.

If you do not want to share the repository between multiple webapps then
I recommend that you write a custom FactoryBean or use JCR Spring
Module [1] to start the repository inside Spring.
In this case you need to have all JR dependencies in in your classpath
(they can be retrieved using Maven).

[1] https://springmodules.dev.java.net/docs/reference/0.9/html/jcr.html#d0e5435

S├ębastien Launay

View raw message