Date: Tue, 19 Mar 2024 06:59:20 +0000 (UTC) Message-ID: <560145026.54559.1710831560872@cwiki-he-fi.apache.org> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_54558_397674699.1710831560872" ------=_Part_54558_397674699.1710831560872 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Today I was contacted with a request to setup the jcr/jackrabbit-s=
erver
bundle in an OSGi framework such that a JCR Repository is bein=
g started and can be accessed from within the OSGi framework and over RMI f=
rom outside of the framework. It happens to be that the framework of choice=
has been Equinox.
So, to better support I decided to setup my own Equinox framework and in= stall required bundles.
First of all, you need the Equinox OSGi framework. You can grab this fro= m the Equinox download page at http://download.eclip= se.org/eclipse/equinox/. I decided to use the latest release stuff, whi= ch at the time of this writing is 3.3.2. So I downloaded the framework jar = file org.eclipse.osgi_3.3.2.R33x_v2= 0080105.jar
One this has been downloaded, it can easily be started from the command =
line. As I required the console prompt, I added the -console
c=
ommand line option:
$ java -jar o= rg.eclipse.osgi_3.3.2.R33x_v20080105.jar -console osgi> ss Framework is launched. id State Bundle 0 ACTIVE org.eclipse.osgi_3.3.2.R33x_v20080105 osgi>=20
The console gives you the osgi>
prompt to which I entere=
d a first ss
command to get a short status of installed bundle=
s. This lists just the system bundle with ID 0. This console is used by us =
to interactively install and start additional bundles, until we get a runni=
ng Jackrabbit Repository.
To get a list of available commands just enter the help
com=
mand. Some commands which we will use later on are :
<id>
. This list includes=
registered and used services, import and export packages and some more inf=
ormation.<url>
. Note that this must be a real URL, that =
is to install a file from the local filesystem, the file:
prot=
ocoll must be specified.<id>
.<id>
.<id>
.First we need to install OSGi Compendium Services bundles:
We chose to mainly use Equinox implementations, so we get the org.eclipse.osgi.services_3.1.200.v20= 070605.jar bundle to install the OSGi Compendium Services API:
osgi> inst= all <url> Bundle id is 1 osgi> start 1 osgi> ss Framework is launched. id State Bundle 0 ACTIVE org.eclipse.osgi_3.3.2.R33x_v20080105 1 ACTIVE org.eclipse.osgi.services_3.1.200.v20070605 osgi>=20
Note that bundles are not automatically started after the installation. = Therefore we have to manually start the bundles after the installation. Thi= s manual start is only required after the installation. On framework restar= ts all bundles, which were started when the framework was last shutdown, ar= e automatically restarted.
We continue with the LogService. Here we could of course also choose to = use the Equinox implementation. But as I know, that Jackrabbit uses SLF4J= a> for logging and some other components use log4j and Jakarta Commons Logg= ing, I strongly suggest to use the LogService implementation from the Sling= project. This bundle unifies all logging requests from the OSGi LogService= and the SLF4J, log4j and Jakarta Commons Logging API into a single log cha= nnel. This makes problem traking much easier.
The Sling LogService implementation is available from the Apache Snapsho= t repository and may be directly installed into the OSGi framework:
osgi> inst= all <url> Bundle id is 2 osgi> start 2=20 30.04.2008 21:13:24.642 *INFO* [OSGi Console] org.apache.sling.osgi.log.Log= ServiceFactory LogManager: Logging set up from context 30.04.2008 21:13:24.645 *INFO* [OSGi Console] org.apache.sling.osgi.log Ser= vice [org.apache.sling.osgi.log.LogServiceFactory,22] ServiceEvent REGISTER= ED 30.04.2008 21:13:24.646 *INFO* [OSGi Console] org.apache.sling.osgi.log Ser= vice [org.apache.sling.osgi.log.LogReaderServiceFactory,23] ServiceEvent RE= GISTERED osgi> 30.04.2008 21:13:24.646 *INFO* [Framework Event Dispatcher] org.ap= ache.sling.osgi.log BundleEvent STARTED osgi> ss Framework is launched. id State Bundle 0 ACTIVE org.eclipse.osgi_3.3.2.R33x_v20080105 1 ACTIVE org.eclipse.osgi.services_3.1.200.v20070605 2 ACTIVE org.apache.sling.osgi.log_2.0.0.incubator-SNAPSHOT osgi>=20
We installed the LogService implementation early in the process to be ab= le to get some logging in the future processing. You may have noticed, that= LogService already kicked in writing logs to stdout. In the further steps = you will notice, that each bundle installation and start will be accompanie= d with log messages.
Core configuration to launche the Jackrabbit repository is maintained us= ing the OSGi Configuration Admin Service. For the moment this configuration= just encompasses the filesystem location of the repository and the path to= the repository configuration file. In the future this may be extended if c= onfiguration options for Jackrabbit may change.
For the sake of using Equinox bundles, lets take the Equinox implementat= ion of the Configuration Admin Service available from org.eclipse.equinox.cm_3.2.0.v20070116.jar.
osgi> inst= all <url> Bundle id is 4 osgi> 30.04.2008 21:22:16.042 *INFO* [Framework Event Dispatcher] org.ec= lipse.equinox.cm BundleEvent INSTALLED start 4 30.04.2008 21:22:19.921 *INFO* [Framework Event Dispatcher] org.eclipse.equ= inox.cm BundleEvent RESOLVED 30.04.2008 21:22:19.949 *INFO* [OSGi Console] org.eclipse.equinox.cm Servic= e [24] ServiceEvent REGISTERED 30.04.2008 21:22:19.973 *INFO* [Framework Event Dispatcher] org.eclipse.equ= inox.cm BundleEvent STARTED osgi> ss Framework is launched. id State Bundle 0 ACTIVE org.eclipse.osgi_3.3.2.R33x_v20080105 1 ACTIVE org.eclipse.osgi.services_3.1.200.v20070605 2 ACTIVE org.apache.sling.osgi.log_2.0.0.incubator-SNAPSHOT 4 ACTIVE org.eclipse.equinox.cm_3.2.0.v20070116 osgi>=20
The last OSGi Compendium Service implementation we need is Declarative S= ervices. I of course also tried the Equinox implementation of this specific= ation. But unfortunately the Sling Jackrabbit Repository bundle cannot be u= sed with this implementation. This is of course not a good thing and we wil= l try to find out, what is wrong here. This issue is tracked as SLING-408. So we take the Apache Felix implementation fr= om org.apache.felix.scr-1.0.0.jar.
osgi> inst= all <url> Bundle id is 5 30.04.2008 22:12:34.988 *INFO* [Framework Event Dispatcher] org.apache.feli= x.scr BundleEvent INSTALLED osgi> start 5 30.04.2008 22:12:38.032 *INFO* [Framework Event Dispatcher] org.apache.feli= x.scr BundleEvent RESOLVED 30.04.2008 22:12:38.033 *INFO* [OSGi Console] org.apache.felix.scr Service = [Declarative Services Management Agent,25] ServiceEvent REGISTERED osgi> 30.04.2008 22:12:38.039 *INFO* [Framework Event Dispatcher] org.ap= ache.felix.scr BundleEvent STARTED ss Framework is launched. id State Bundle 0 ACTIVE org.eclipse.osgi_3.3.2.R33x_v20080105 1 ACTIVE org.eclipse.osgi.services_3.1.200.v20070605 2 ACTIVE org.apache.sling.osgi.log_2.0.0.incubator-SNAPSHOT 4 ACTIVE org.eclipse.equinox.cm_3.2.0.v20070116 5 ACTIVE org.apache.felix.scr_1.0.0 osgi>
The next (and final) big step is to install and start the bundles requir= ed to embed and start the Jackrabbit repository. In short, we are going to = install the following bundles:
We start with the helper libraries Jakarta Commons Collections and Jackr= abbit Commons. Fortunately the latest releases of both libraries already co= me built ready as OSGi bundles. So we just grab the respective libraries fr= om the Maven 2 repository and install them as is:
osgi> inst= all <url> Bundle id is 6 osgi> 01.05.2008 20:31:33.553 *INFO* [Framework Event Dispatcher] org.ap= ache.commons.collections BundleEvent INSTALLED start 6 osgi> 01.05.2008 20:31:38.374 *INFO* [Framework Event Dispatcher] org.ap= ache.commons.collections BundleEvent RESOLVED 01.05.2008 20:31:38.374 *INFO* [Framework Event Dispatcher] org.apache.comm= ons.collections BundleEvent STARTED install <url> Bundle id is 7 01.05.2008 20:32:58.959 *INFO* [Framework Event Dispatcher] org.apache.jack= rabbit.jackrabbit-jcr-commons BundleEvent INSTALLED osgi> start 7 org.osgi.framework.BundleException: The bundle could not be resolved. Reaso= n: Missing Constraint: Import-Package: javax.jcr; version=3D"0.0.0" at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(= BundleHost.java:305) at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(Ab= stractBundle.java:260) at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(Ab= stractBundle.java:252) at org.eclipse.osgi.framework.internal.core.FrameworkCommandProvide= r._start(FrameworkCommandProvider.java:260) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessor= Impl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethod= AccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpr= eter.execute(FrameworkCommandInterpreter.java:150) at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docomm= and(FrameworkConsole.java:300) at org.eclipse.osgi.framework.internal.core.FrameworkConsole.consol= e(FrameworkConsole.java:285) at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(Fr= ameworkConsole.java:221) at java.lang.Thread.run(Thread.java:619) osgi> ss Framework is launched. id State Bundle 0 ACTIVE org.eclipse.osgi_3.3.2.R33x_v20080105 1 ACTIVE org.eclipse.osgi.services_3.1.200.v20070605 2 ACTIVE org.apache.sling.osgi.log_2.0.0.incubator-SNAPSHOT 4 ACTIVE org.eclipse.equinox.cm_3.2.0.v20070116 5 ACTIVE org.apache.felix.scr_1.0.0 6 ACTIVE org.apache.commons.collections_3.2.1 7 INSTALLED org.apache.jackrabbit.jackrabbit-jcr-commons_1.4.2 osgi>=20
Oops ! Bundle 7, the Jackrabbit Commons library bundle, fails to start. = The reason for this is, that this library depends on the Content Repository= for Java (JCR) API classes, which have not be installed yet and which are = not available from the environment either.
This is not actually a problem because the Sling JCR API bundle exports = just these packages. So lets just continue with the next steps.
The Sling JCR API and Base Bundles can be installed directly from the Ap= ache Snapshot Repository, which we just do now:
osgi> inst= all <url> Bundle id is 8 osgi> 01.05.2008 20:37:21.866 *INFO* [Framework Event Dispatcher] org.ap= ache.sling.jcr.api BundleEvent INSTALLED start 8 01.05.2008 20:37:28.099 *INFO* [Framework Event Dispatcher] org.apache.slin= g.jcr.api BundleEvent RESOLVED 01.05.2008 20:37:28.100 *INFO* [Framework Event Dispatcher] org.apache.jack= rabbit.jackrabbit-jcr-commons BundleEvent RESOLVED osgi> 01.05.2008 20:37:28.100 *INFO* [Framework Event Dispatcher] org.ap= ache.sling.jcr.api BundleEvent STARTED install <url> Bundle id is 9 01.05.2008 20:38:45.563 *INFO* [Framework Event Dispatcher] org.apache.slin= g.jcr.base BundleEvent INSTALLED osgi> start 9 01.05.2008 20:38:51.069 *INFO* [Framework Event Dispatcher] org.apache.slin= g.jcr.base BundleEvent RESOLVED 01.05.2008 20:38:51.069 *INFO* [Framework Event Dispatcher] org.apache.slin= g.jcr.base BundleEvent STARTED osgi> ss Framework is launched. id State Bundle 0 ACTIVE org.eclipse.osgi_3.3.2.R33x_v20080105 1 ACTIVE org.eclipse.osgi.services_3.1.200.v20070605 2 ACTIVE org.apache.sling.osgi.log_2.0.0.incubator-SNAPSHOT 4 ACTIVE org.eclipse.equinox.cm_3.2.0.v20070116 5 ACTIVE org.apache.felix.scr_1.0.0 6 ACTIVE org.apache.commons.collections_3.2.1 7 RESOLVED org.apache.jackrabbit.jackrabbit-jcr-commons_1.4.2 8 ACTIVE org.apache.sling.jcr.api_2.0.0.incubator-SNAPSHOT 9 ACTIVE org.apache.sling.jcr.base_2.0.0.incubator-SNAPSHOT osgi>
Now that we have installed the API and base bundles, we see that bundle = 7 is now in the RESOLVED state. That is, the imports could now be = completely resolved. In fact, the bundle has been resolved because the JCR = Base Bundle (Bundle 9) requires the classes exported by bundle 7. So we can= now start bundle 7:
osgi> star= t 7 osgi> 01.05.2008 20:39:03.845 *INFO* [Framework Event Dispatcher] org.ap= ache.jackrabbit.jackrabbit-jcr-commons BundleEvent STARTED ss Framework is launched. id State Bundle 0 ACTIVE org.eclipse.osgi_3.3.2.R33x_v20080105 1 ACTIVE org.eclipse.osgi.services_3.1.200.v20070605 2 ACTIVE org.apache.sling.osgi.log_2.0.0.incubator-SNAPSHOT 4 ACTIVE org.eclipse.equinox.cm_3.2.0.v20070116 5 ACTIVE org.apache.felix.scr_1.0.0 6 ACTIVE org.apache.commons.collections_3.2.1 7 ACTIVE org.apache.jackrabbit.jackrabbit-jcr-commons_1.4.2 8 ACTIVE org.apache.sling.jcr.api_2.0.0.incubator-SNAPSHOT 9 ACTIVE org.apache.sling.jcr.base_2.0.0.incubator-SNAPSHOT osgi>=20
Finally we install and start the Jackrabbit Repository and Text Extracto= r Bundles:
osgi> inst= all <url> 01.05.2008 20:45:57.183 *INFO* [Framework Event Dispatcher] org.apache.slin= g.jcr.jackrabbit-text-extractors BundleEvent INSTALLED Bundle id is 10 osgi> install <url> Bundle id is 11 osgi> 01.05.2008 21:19:05.079 *INFO* [Framework Event Dispatcher] org.ap= ache.sling.jcr.jackrabbit.server BundleEvent INSTALLED start 10 osgi> 01.05.2008 21:19:27.219 *INFO* [Framework Event Dispatcher] org.ap= ache.sling.jcr.jackrabbit-text-extractors BundleEvent STARTED start 11 01.05.2008 21:19:30.940 *INFO* [Framework Event Dispatcher] org.apache.slin= g.jcr.jackrabbit.server BundleEvent RESOLVED 01.05.2008 21:19:31.058 *INFO* [OSGi Console] org.apache.sling.jcr.jackrabb= it.server.Activator Creating default config for Jackrabbit in jackrabbit 01.05.2008 21:19:31.075 *INFO* [OSGi Console] org.apache.sling.jcr.jackrabb= it.server.Activator verifyConfiguration: Created configuration org.apache.s= ling.jcr.jackrabbit.server.SlingServerRepository-1209669571062-0 for org.ap= ache.sling.jcr.jackrabbit.server.SlingServerRepository 01.05.2008 21:19:31.096 *INFO* [OSGi Console] org.apache.sling.jcr.jackrabb= it.server Service [org.apache.sling.jcr.jackrabbit.server.JndiRegistrationS= upport,26] ServiceEvent REGISTERED 01.05.2008 21:19:31.153 *INFO* [SCR Component Actor] org.apache.sling.jcr.j= ackrabbit.server Using JNDI context {java.naming.provider.url=3Dhttp://incu= bator.apache.org/sling, java.naming.factory.initial=3Dorg.apache.jackrabbit= .core.jndi.provider.DummyInitialContextFactory} to register repositories 01.05.2008 21:19:31.153 *INFO* [OSGi Console] org.apache.sling.jcr.jackrabb= it.server Service [org.apache.sling.jcr.jackrabbit.server.RmiRegistrationSu= pport,27] ServiceEvent REGISTERED 01.05.2008 21:19:31.155 *INFO* [SCR Component Actor] org.apache.sling.jcr.j= ackrabbit.server Using RMI Registry port 1099 01.05.2008 21:19:31.156 *INFO* [SCR Component Actor] org.apache.sling.jcr.j= ackrabbit.server Service [org.apache.sling.jcr.jackrabbit.server.SlingServe= rRepository,28] ServiceEvent REGISTERED osgi> 01.05.2008 21:19:31.169 *INFO* [Framework Event Dispatcher] org.ap= ache.sling.jcr.jackrabbit.server BundleEvent STARTED 01.05.2008 21:19:31.283 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.RepositoryImpl Starting repository... 01.05.2008 21:19:31.294 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.fs.local.LocalFileSystem LocalFileSystem initialized at path jackrabbi= t/repository 01.05.2008 21:19:31.433 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.nodetype.NodeTypeRegistry no custom node type definitions found 01.05.2008 21:19:31.453 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.fs.local.LocalFileSystem LocalFileSystem initialized at path jackrabbi= t/version 01.05.2008 21:19:32.555 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.persistence.db.DatabasePersistenceManager Database: Apache Derby / 10.= 2.1.6 - (452058) 01.05.2008 21:19:32.555 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.persistence.db.DatabasePersistenceManager Driver: Apache Derby Embedde= d JDBC Driver / 10.2.1.6 - (452058) 01.05.2008 21:19:33.060 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.fs.local.LocalFileSystem LocalFileSystem initialized at path jackrabbi= t/version/blobs 01.05.2008 21:19:33.105 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.RepositoryImpl initializing workspace 'default'... 01.05.2008 21:19:33.106 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.fs.local.LocalFileSystem LocalFileSystem initialized at path jackrabbi= t/workspaces/default 01.05.2008 21:19:33.620 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.persistence.db.DatabasePersistenceManager Database: Apache Derby / 10.= 2.1.6 - (452058) 01.05.2008 21:19:33.620 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.persistence.db.DatabasePersistenceManager Driver: Apache Derby Embedde= d JDBC Driver / 10.2.1.6 - (452058) 01.05.2008 21:19:33.870 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.fs.local.LocalFileSystem LocalFileSystem initialized at path jackrabbi= t/workspaces/default/blobs 01.05.2008 21:19:33.914 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.RepositoryImpl workspace 'default' initialized 01.05.2008 21:19:34.043 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.fs.local.LocalFileSystem LocalFileSystem initialized at path jackrabbi= t/repository/index 01.05.2008 21:19:34.865 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.query.lucene.SearchIndex Index initialized: jackrabbit/repository/inde= x Version: 2 01.05.2008 21:19:34.868 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.fs.local.LocalFileSystem LocalFileSystem initialized at path jackrabbi= t/workspaces/default/index 01.05.2008 21:19:34.869 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.query.lucene.SearchIndex Index initialized: jackrabbit/workspaces/defa= ult/index Version: 2 01.05.2008 21:19:34.870 *INFO* [SCR Component Actor] org.apache.jackrabbit.= core.RepositoryImpl Repository started 01.05.2008 21:19:35.017 *INFO* [SCR Component Actor] org.apache.sling.jcr.j= ackrabbit.server Service [org.apache.sling.jcr.jackrabbit.server.SlingServe= rRepository-1209669571062-0,29] ServiceEvent REGISTERED 01.05.2008 21:19:35.018 *INFO* [SCR Component Actor] org.apache.sling.jcr.j= ackrabbit.server Repository bound to JNDI as jackrabbit 01.05.2008 21:19:35.164 *INFO* [SCR Component Actor] org.apache.sling.jcr.j= ackrabbit.server Using private RMI Registry at 1099 01.05.2008 21:19:35.165 *INFO* [SCR Component Actor] org.apache.sling.jcr.j= ackrabbit.server Repository bound to //bslm-046.corp.day.com:1099/jackrabbi= t ss Framework is launched. id State Bundle 0 ACTIVE org.eclipse.osgi_3.3.2.R33x_v20080105 1 ACTIVE org.eclipse.osgi.services_3.1.200.v20070605 2 ACTIVE org.apache.sling.osgi.log_2.0.0.incubator-SNAPSHOT 4 ACTIVE org.eclipse.equinox.cm_3.2.0.v20070116 5 ACTIVE org.apache.felix.scr_1.0.0 6 ACTIVE org.apache.commons.collections_3.2.1 7 ACTIVE org.apache.jackrabbit.jackrabbit-jcr-commons_1.4.2 8 ACTIVE org.apache.sling.jcr.api_2.0.0.incubator-SNAPSHOT 9 ACTIVE org.apache.sling.jcr.base_2.0.0.incubator-SNAPSHOT 10 ACTIVE org.apache.sling.jcr.jackrabbit-text-extractors_1.4.0.i= ncubator-SNAPSHOT 11 ACTIVE org.apache.sling.jcr.jackrabbit.server_2.0.0.incubator-= SNAPSHOT osgi>=20
Wow! After starting the Text Extractors and Jackrabbit Server bundles, t=
he repository is immediately starting and is then available as an OSGi serv=
ice of type javax.jcr.Repository
and over RMI using the RMI UR=
L //localhost:1099/jackrabbit
That's it. Now, you can install more bundles and enjoy the fun of progra= mming the Content Repository for Java API.
This is a complete list of the links to the files we needed during downl= oad. Note, that some links are behind a mirroring scripts (mostly the Equin= ox download links).
Description |
Link |
---|---|
Equinox OSGi Framework |
|
OSGi Compendium Services API |
|
Sling OSGi LogService Implementation |
org.apache.sling.osgi.log-2.0.0= -incubator-20080430.113337-26.jar |
Equinox OSGi Configuration Admin Service Impl= ementation |
|
Felix OSGi Declarative Service Implementation= |
|
Jakarta Commons Collections |
|
Jackrabbit Commons |
|
Sling JCR API Bundle |
org.apache.sling.jcr.api-2.0.0-in= cubator-20080430.113337-29.jar |
Sling JCR Base Bundle |
org.apache.sling.jcr.base-2.0.0= -incubator-20080501.182241-31.jar |
Sling Jackrabbit Text Extractors Bundle = td> | org.apache.sling.jcr.jackrabbit-text-extractors-1.4.0= -0003-incubator-20080430.113337-9.jar |
Sling Jackrabbit Embedded Repository Bundle= p> |
org.a= pache.sling.jcr.jackrabbit.server-2.0.0-incubator-20080501.191424-29.jar |