Jackrabbit Oak: Getting started and connect to a standalone repository via RMI

我是研究僧i 提交于 2019-12-11 07:39:12

问题


I am totally new to Jackrabbit and Jackrabbit Oak. I worked a lot with Alfresco though, another JCR compliant open-source content repo.

I want to start a standalone Jackrabbit Oak repo, then connect to it via Java code. Unfortunately the Oak documentation is quite scarce.

I checked out the Oak repo, built it with mvn clean install and then ran the standalone server (memory repository is fine for me at the moment for testing) via:

$ java -jar oak-run-1.6-SNAPSHOT.jar server

Apache Jackrabbit Oak 1.6-SNAPSHOT
Starting Oak-Memory repository -> http://localhost:8080/
13:14:38.317 [main] WARN  o.a.j.s.r.d.ProtectedRemoveManager - protectedhandlers-config is missing -> DIFF processing can fail for the Remove operation if the content toremove is protected!

When I open http://localhost:8080/ I see a blank page with code like this but the html / xhtml output as source like this:

I try to connect via Java code:

JcrUtils.getRepository("http://localhost:8080");
// or
JcrUtils.getRepository("http://localhost:8080/rmi");

but getting:

Connecting to http://localhost:8080
Exception in thread "main" javax.jcr.RepositoryException: Unable to access a repository with the following settings:
    org.apache.jackrabbit.repository.uri: http://localhost:8080
The following RepositoryFactory classes were consulted:
    org.apache.jackrabbit.oak.jcr.OakRepositoryFactory: declined
    org.apache.jackrabbit.commons.JndiRepositoryFactory: declined
Perhaps the repository you are trying to access is not available at the moment.
    at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:223)
    at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:263)
    at Main.main(Main.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

(The Oak documentation is not as complete as the Jackrabbit documentation, but I am also not sure how much of Jackrabbit 2 is still valid for Oak, since it's a complete rewrite.)

I found the same question in the mailing list/Nabble, but the provided answer there does not use a remote, standalone repository but a local one running in the same servlet container and even app (just that eventually the Mongo DB / Node store is configured as remote, but that would mean that the Mongo ports would need to be open). So the app creates the repository itself, which is not my case (I got this case working fine in Oak as well).

In Jackrabbit2 (not Oak), I can simply connect via

Repository repo = new URLRemoteRepository("http://localhost:8080/rmi");

and it's working fine, but this method is not available for Oak, it seems.

Is RMI not enabled by default in Oak? Is there a different URI to use?

However, the documentation of Oak says "Oak comes with a runnable jar" and the runnable jar offers the server method to start the server, so I assume that my scenario above is a valid one.


回答1:


The blank page is a result of your browser being unable to parse the<title/> tag.

Go into developer mode to see how the browser incorrectly interpreted that tag.

Incorrect interpretation of title tag




回答2:


i never saw an example of jackrabbit oak working like this.. are you sure it is possible to start oak outside of your application? How do you set up the persistent store? (which one are you going to use?).

Here is the link how you normally set up jackrabbit oak: https://jackrabbit.apache.org/oak/docs/construct.html

For example if you use MongoDB as backend (which is the most powerful), you first connect to the db via

Db db = new MongoClient(ip, port).getDB("testDB");

where ip is the ip-address of your MongoDB-server with its port. This server doesn't need to be on the same machine like your Java code is running. You can even use instead of a single MongoDB instance a Replica set. The same is valid by using a relational db.. only if you choose the tar-file system backend you are limited to your local machine. Then, in a second step you create a jcr based on the chosen backend (see the link)



来源:https://stackoverflow.com/questions/40191705/jackrabbit-oak-getting-started-and-connect-to-a-standalone-repository-via-rmi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!