目标:使用Apache Oak作为JCR提供程序运行Apache Sling,并将MongoDB作为后备数据存储区。
步骤到目前为止: 安装了MongoDB(3.0.2)并验证并运行 克隆:https://github.com/apache/sling.git 使用maven构建:mvn clean install 使用以下命令在本地运行:
java -jar target/org.apache.sling.launchpad-*.jar -c test -f -
这很好用,但现在我想转而使用Apache Oak和MongoDB。 Launchpad App文档似乎描述了执行以下操作的可能性:
java -jar target/org.apache.sling.launchpad-*.jar -Dsling.run.modes=oak,oak_mongo
但是,当我这样做时,我没有看到与正在运行的Mongo实例建立任何连接。
已审核文档到目前为止:
输入启动板/构建器目录并首次启动Sling
$ cd launchpad/builder
$ java -jar target/org.apache.sling.launchpad-*.jar -c test -f -
更新:2015年5月19日
正如罗伯特建议的那样,我已经启动了一个2.6.8的Mongo实例,并尝试启动Sling以查看是否存在任何连接:( Mongo日志中出现的连接来自与RoboMongo的连接而不是据我所知,吊索。浏览http://localhost:8080/.explorer.html#,不会触发Mongo日志中的任何输出。
Mongo终端日志
/usr/local/Cellar/mongodb/2.6.8/bin [master]
± % ./mongod !1778
./mongod --help for help and startup options
2015-05-19T13:51:27.831-0500 [initandlisten] MongoDB starting : pid=42458 port=27017 dbpath=/data/db 64-bit host=Davids-MacBook-Pro-3.local
2015-05-19T13:51:27.831-0500 [initandlisten]
2015-05-19T13:51:27.831-0500 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2015-05-19T13:51:27.831-0500 [initandlisten] db version v2.6.8
2015-05-19T13:51:27.831-0500 [initandlisten] git version: nogitversion
2015-05-19T13:51:27.831-0500 [initandlisten] build info: Darwin miniyosemite.local 14.1.0 Darwin Kernel Version 14.1.0: Mon Dec 22 23:10:38 PST 2014; root:xnu-2782.10.72~2/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2015-05-19T13:51:27.831-0500 [initandlisten] allocator: tcmalloc
2015-05-19T13:51:27.831-0500 [initandlisten] options: {}
2015-05-19T13:51:27.836-0500 [initandlisten] journal dir=/data/db/journal
2015-05-19T13:51:27.836-0500 [initandlisten] recover : no journal files present, no recovery needed
2015-05-19T13:51:28.294-0500 [initandlisten] waiting for connections on port 27017
2015-05-19T13:52:28.338-0500 [clientcursormon] mem (MB) res:97 virt:3295
2015-05-19T13:52:28.338-0500 [clientcursormon] mapped (incl journal view):800
2015-05-19T13:52:28.338-0500 [clientcursormon] connections:0
2015-05-19T13:57:28.529-0500 [clientcursormon] mem (MB) res:97 virt:3295
2015-05-19T13:57:28.529-0500 [clientcursormon] mapped (incl journal view):800
2015-05-19T13:57:28.529-0500 [clientcursormon] connections:0
2015-05-19T14:02:28.710-0500 [clientcursormon] mem (MB) res:97 virt:3295
2015-05-19T14:02:28.710-0500 [clientcursormon] mapped (incl journal view):800
2015-05-19T14:02:28.710-0500 [clientcursormon] connections:0
2015-05-19T14:07:28.899-0500 [clientcursormon] mem (MB) res:97 virt:3295
2015-05-19T14:07:28.899-0500 [clientcursormon] mapped (incl journal view):800
2015-05-19T14:07:28.899-0500 [clientcursormon] connections:0
2015-05-19T14:12:29.096-0500 [clientcursormon] mem (MB) res:97 virt:3295
2015-05-19T14:12:29.096-0500 [clientcursormon] mapped (incl journal view):800
2015-05-19T14:12:29.096-0500 [clientcursormon] connections:0
2015-05-19T14:17:29.289-0500 [clientcursormon] mem (MB) res:97 virt:3295
2015-05-19T14:17:29.289-0500 [clientcursormon] mapped (incl journal view):800
2015-05-19T14:17:29.289-0500 [clientcursormon] connections:0
2015-05-19T14:22:29.522-0500 [clientcursormon] mem (MB) res:97 virt:3295
2015-05-19T14:22:29.522-0500 [clientcursormon] mapped (incl journal view):800
2015-05-19T14:22:29.522-0500 [clientcursormon] connections:0
2015-05-19T15:00:05.966-0500 [clientcursormon] mem (MB) res:97 virt:3295
2015-05-19T15:00:05.966-0500 [clientcursormon] mapped (incl journal view):800
2015-05-19T15:00:05.966-0500 [clientcursormon] connections:0
2015-05-19T15:03:52.664-0500 [initandlisten] connection accepted from 127.0.0.1:64394 #1 (1 connection now open)
2015-05-19T15:03:52.674-0500 [initandlisten] connection accepted from 127.0.0.1:64395 #2 (2 connections now open)
2015-05-19T15:04:11.610-0500 [initandlisten] connection accepted from 127.0.0.1:64453 #3 (3 connections now open)
2015-05-19T15:04:11.620-0500 [initandlisten] connection accepted from 127.0.0.1:64454 #4 (4 connections now open)
2015-05-19T15:04:27.788-0500 [conn3] end connection 127.0.0.1:64453 (3 connections now open)
2015-05-19T15:04:27.788-0500 [conn4] end connection 127.0.0.1:64454 (3 connections now open)
2015-05-19T15:04:27.795-0500 [conn2] end connection 127.0.0.1:64395 (1 connection now open)
2015-05-19T15:04:27.796-0500 [conn1] end connection 127.0.0.1:64394 (0 connections now open)
吊索终端日志
java -jar org.apache.sling.launchpad-8-SNAPSHOT.jar -Dsling.run.modes=oak_mongo !1804
19.05.2015 15:14:24.777 *INFO * [main] Setting sling.home=sling (default)
19.05.2015 15:14:24.778 *INFO * [main] Starting Apache Sling in /Users/dholtz/projects/git/sling/launchpad/builder/target/sling
19.05.2015 15:14:24.780 *INFO * [main] Sling Extension Lib Home : /Users/dholtz/projects/git/sling/launchpad/builder/target/sling/ext
19.05.2015 15:14:24.781 *INFO * [main] Checking launcher JAR in folder /Users/dholtz/projects/git/sling/launchpad/builder/target/sling
19.05.2015 15:14:24.804 *INFO * [main] Installing new launcher: jar:file:/Users/dholtz/projects/git/sling/launchpad/builder/target/org.apache.sling.launchpad-8-SNAPSHOT.jar!/resources/org.apache.sling.launchpad.base.jar, 5.0.0.2_6_0 (org.apache.sling.launchpad.base.jar.1432066464804)
19.05.2015 15:14:24.817 *INFO * [main] Loading launcher class org.apache.sling.launchpad.base.app.MainDelegate from org.apache.sling.launchpad.base.jar.1432066464804
19.05.2015 15:14:24.817 *INFO * [main] External Libs Home (ext) is null or does not exists.
19.05.2015 15:14:24.840 *INFO * [main] Setting sling.run.modes=oak_mongo
19.05.2015 15:14:24.840 *INFO * [main] Setting sling.launchpad=/Users/dholtz/projects/git/sling/launchpad/builder/target/sling
19.05.2015 15:14:24.840 *INFO * [main] Starting launcher ...
19.05.2015 15:14:24.840 *INFO * [main] HTTP server port: 8080
19.05.2015 15:14:25.561 *INFO* [FelixStartLevel] org.apache.sling.commons.logservice Service [org.apache.sling.commons.logservice.internal.LogServiceFactory,18, [org.osgi.service.log.LogService]] ServiceEvent REGISTERED
19.05.2015 15:14:25.564 *INFO* [FelixStartLevel] org.apache.sling.commons.logservice Service [org.apache.sling.commons.logservice.internal.LogReaderServiceFactory,19, [org.osgi.service.log.LogReaderService]] ServiceEvent REGISTERED
19.05.2015 15:14:25.566 *INFO* [FelixStartLevel] org.apache.sling.commons.logservice BundleEvent STARTED
19.05.2015 15:14:25.569 *INFO* [FelixStartLevel] org.apache.sling.installer.core BundleEvent RESOLVED
19.05.2015 15:14:25.570 *INFO* [FelixStartLevel] org.apache.sling.installer.core BundleEvent STARTING
19.05.2015 15:14:25.793 *INFO * [main] Startup completed
更新:2015年5月20日
Per Roberts的建议:
你的日志中的runmodes不正确,你应该使用-Dsling.run.modes = oak,oak_mongo -
改变了runmodes和reran Sling。
error.log
20.05.2015 12:59:27.745 *ERROR* [CM Event Dispatcher (Fire ConfigurationEvent: pid=org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService)] org.apache.jackrabbit.oak-core [org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService(17)] The activate method has thrown an exception (java.lang.NoClassDefFoundError: com/mongodb/MongoClientOptions$Builder)
java.lang.NoClassDefFoundError: com/mongodb/MongoClientOptions$Builder
at org.apache.jackrabbit.oak.plugins.document.util.MongoConnection.getDefaultBuilder(MongoConnection.java:85)
at org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService.registerNodeStore(DocumentNodeStoreService.java:375)
at org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService.registerNodeStoreIfPossible(DocumentNodeStoreService.java:324)
at org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService.activate(DocumentNodeStoreService.java:310)
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:497)
at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:231)
at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:39)
at org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:624)
at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:508)
at org.apache.felix.scr.impl.helper.ActivateMethod.invoke(ActivateMethod.java:149)
at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:315)
at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:127)
at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:871)
at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:838)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:850)
at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure(SingleComponentManager.java:623)
at org.apache.felix.scr.impl.config.ConfigurableComponentHolder.configurationUpdated(ConfigurableComponentHolder.java:328)
at org.apache.felix.scr.impl.config.ConfigurationSupport.configurationEvent(ConfigurationSupport.java:290)
at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.sendEvent(ConfigurationManager.java:2036)
at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.run(ConfigurationManager.java:2005)
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:103)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.mongodb.MongoClientOptions$Builder not found by org.apache.jackrabbit.oak-core [48]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1558)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1998)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 25 common frames omitted
更新:06/04/2015
根据罗伯特的最新建议,似乎成功连接到mongodb。如上所述,但有一些例外情况被抛出。
答案 0 :(得分:0)
据我所知,我们目前在Sling中使用的Oak 1.2在MongoDB 2.6.x上进行了测试。您可以尝试使用最新的2.6.x版MongoDB而不是3.0.x吗?
如果可以,并且您想使用最新版本的MongoDB,则应使用最新的驱动程序,例如:将补丁应用于Sling git repo,如
diff --git a/launchpad/builder/src/main/provisioning/oak.txt b/launchpad/builder/src/main/provisioning/oak.txt
index 64decb2..8f5edb6 100644
--- a/launchpad/builder/src/main/provisioning/oak.txt
+++ b/launchpad/builder/src/main/provisioning/oak.txt
@@ -36,7 +36,7 @@
org.apache.jackrabbit/oak-blob/${oak.version}
[artifacts startLevel=15 runModes=oak_mongo]
- org.mongodb/mongo-java-driver/2.12.2
+ org.mongodb/mongo-java-driver/3.0.1
[configurations runModes=oak]
org.apache.felix.jaas.Configuration.factory-GuestLoginModule