You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Mark Adamcin <ad...@gmail.com> on 2019/05/03 17:06:26 UTC
Possible to open existing JCR repository using read-only FileStore?
I'm trying to create a tool to export some JCR data (such as a list of
nodetypes as a CND, and maybe even to run a query) from an existing oak
repository directory without risking mutation of the filestore. While I am
able to follow the patterns used by oak-run to get a NodeStoreFixture with
a readonly FileStore, when I attempt to construct an Oak() instance and a
Jcr() builder on top of it, the Oak.createNewContentRepository() method
throws when it attempts to merge an "OakInitializer" commit to the
SegmentNodeStore.
Is it possible to avoid this commit to support a readonly JCR session? Or
would this have to be mounted to a separate JCR repository using a
CompositeNodeStore?
Stack trace from oak 1.8.9:
java.lang.UnsupportedOperationException: Cannot write to read-only store
at
org.apache.jackrabbit.oak.segment.DefaultSegmentWriterBuilder$1.execute(DefaultSegmentWriterBuilder.java:176)
at
org.apache.jackrabbit.oak.segment.DefaultSegmentWriter.writeNode(DefaultSegmentWriter.java:243)
at
org.apache.jackrabbit.oak.segment.SegmentWriter.writeNode(SegmentWriter.java:141)
at
org.apache.jackrabbit.oak.segment.SegmentNodeBuilder.getNodeState(SegmentNodeBuilder.java:132)
at
org.apache.jackrabbit.oak.segment.scheduler.Commit.hasChanges(Commit.java:102)
at
org.apache.jackrabbit.oak.segment.scheduler.LockBasedScheduler.execute(LockBasedScheduler.java:258)
at
org.apache.jackrabbit.oak.segment.scheduler.LockBasedScheduler.schedule(LockBasedScheduler.java:236)
at
org.apache.jackrabbit.oak.segment.SegmentNodeStore.merge(SegmentNodeStore.java:195)
at
org.apache.jackrabbit.oak.OakInitializer.initialize(OakInitializer.java:54)
at
org.apache.jackrabbit.oak.Oak.createNewContentRepository(Oak.java:687)
at org.apache.jackrabbit.oak.Oak.createContentRepository(Oak.java:675)
at
org.apache.jackrabbit.oak.jcr.Jcr.createContentRepository(Jcr.java:376)
at org.apache.jackrabbit.oak.jcr.Jcr.createRepository(Jcr.java:385)
at net.adamcin.oakpal.toolslib.JcrFactory.getJcr(JcrFactory.java:54)
Thanks,
Mark Adamcin
Re: Possible to open existing JCR repository using read-only FileStore?
Posted by Francesco Mari <ma...@gmail.com>.
The Jcr builder assumes write access to the repository. The read-only
FileStore is used in CLI utilities and tests that deal directly with the
NodeStore, completely bypassing the JCR API. As far as I know, we don't
have a way to create a read-only JCR Repository.
On Mon, 6 May 2019 at 10:49, Mark Adamcin <ad...@gmail.com> wrote:
> I'm trying to create a tool to export some JCR data (such as a list of
> nodetypes as a CND, and maybe even to run a query) from an existing oak
> repository directory without risking mutation of the filestore. While I am
> able to follow the patterns used by oak-run to get a NodeStoreFixture with
> a readonly FileStore, when I attempt to construct an Oak() instance and a
> Jcr() builder on top of it, the Oak.createNewContentRepository() method
> throws when it attempts to merge an "OakInitializer" commit to the
> SegmentNodeStore.
>
> Is it possible to avoid this commit to support a readonly JCR session? Or
> would this have to be mounted to a separate JCR repository using a
> CompositeNodeStore?
>
> Stack trace from oak 1.8.9:
>
> java.lang.UnsupportedOperationException: Cannot write to read-only store
>
> at
>
> org.apache.jackrabbit.oak.segment.DefaultSegmentWriterBuilder$1.execute(DefaultSegmentWriterBuilder.java:176)
> at
>
> org.apache.jackrabbit.oak.segment.DefaultSegmentWriter.writeNode(DefaultSegmentWriter.java:243)
> at
>
> org.apache.jackrabbit.oak.segment.SegmentWriter.writeNode(SegmentWriter.java:141)
> at
>
> org.apache.jackrabbit.oak.segment.SegmentNodeBuilder.getNodeState(SegmentNodeBuilder.java:132)
> at
>
> org.apache.jackrabbit.oak.segment.scheduler.Commit.hasChanges(Commit.java:102)
> at
>
> org.apache.jackrabbit.oak.segment.scheduler.LockBasedScheduler.execute(LockBasedScheduler.java:258)
> at
>
> org.apache.jackrabbit.oak.segment.scheduler.LockBasedScheduler.schedule(LockBasedScheduler.java:236)
> at
>
> org.apache.jackrabbit.oak.segment.SegmentNodeStore.merge(SegmentNodeStore.java:195)
> at
> org.apache.jackrabbit.oak.OakInitializer.initialize(OakInitializer.java:54)
> at
> org.apache.jackrabbit.oak.Oak.createNewContentRepository(Oak.java:687)
> at org.apache.jackrabbit.oak.Oak.createContentRepository(Oak.java:675)
> at
> org.apache.jackrabbit.oak.jcr.Jcr.createContentRepository(Jcr.java:376)
> at org.apache.jackrabbit.oak.jcr.Jcr.createRepository(Jcr.java:385)
> at net.adamcin.oakpal.toolslib.JcrFactory.getJcr(JcrFactory.java:54)
>
> Thanks,
> Mark Adamcin
>