0

我是 Apache Oak 的新手,正在尝试使用 MongoDB 创建 DocumentNodeStore。以下是详细信息。

<dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-jcr</artifactId>
            <version>1.4.0</version>
        </dependency>
        <dependency>
            <groupId>javax.jcr</groupId>
            <artifactId>jcr</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jclouds</groupId>
            <artifactId>jclouds-all</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jclouds.provider</groupId>
            <artifactId>aws-ec2</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-blob</artifactId>
            <version>1.4.0</version>
        </dependency>
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>3.4.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-commons</artifactId>
            <version>1.4.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-core</artifactId>
            <version>1.4.0</version>
        </dependency>
    </dependencies>

Mongo Db 的版本是 3.4,下面是代码片段。

MongoClient client = new MongoClient("localhost", 27017);
        @SuppressWarnings("deprecation")
        DB db = client.getDB("db");
         DocumentNodeStore ns = new DocumentMK.Builder().
                    setMongoDB(db).getNodeStore();

因此,当我尝试创建 DocumentNodeStore 时,出现以下异常。

Exception in thread "main" com.mongodb.MongoCommandException: Command failed with error 197: 'The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: 1 }, name: "_id_1", ns: "db.blobs", unique: true }' on server localhost:27017. The full response is { "ok" : 0.0, "errmsg" : "The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: 1 }, name: \"_id_1\", ns: \"db.blobs\", unique: true }", "code" : 197, "codeName" : "InvalidIndexSpecificationOption" }
    at com.mongodb.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:115)
    at com.mongodb.connection.CommandProtocol.execute(CommandProtocol.java:114)
    at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:168)
    at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:289)
    at com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:176)
    at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:216)
    at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:207)
    at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:146)
    at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:139)
    at com.mongodb.operation.CreateIndexesOperation$1.call(CreateIndexesOperation.java:150)
    at com.mongodb.operation.CreateIndexesOperation$1.call(CreateIndexesOperation.java:144)
    at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:422)
    at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:413)
    at com.mongodb.operation.CreateIndexesOperation.execute(CreateIndexesOperation.java:144)
    at com.mongodb.operation.CreateIndexesOperation.execute(CreateIndexesOperation.java:71)
    at com.mongodb.Mongo.execute(Mongo.java:845)
    at com.mongodb.Mongo$2.execute(Mongo.java:828)
    at com.mongodb.DBCollection.createIndex(DBCollection.java:1615)
    at org.apache.jackrabbit.oak.plugins.document.mongo.MongoBlobStore.initBlobCollection(MongoBlobStore.java:173)
    at org.apache.jackrabbit.oak.plugins.document.mongo.MongoBlobStore.<init>(MongoBlobStore.java:74)
    at org.apache.jackrabbit.oak.plugins.document.DocumentMK$Builder.setMongoDB(DocumentMK.java:586)
    at org.apache.jackrabbit.oak.plugins.document.DocumentMK$Builder.setMongoDB(DocumentMK.java:604)
    at com.vr.oak.oakdemo.OakDocumentStore.main(OakDocumentStore.java:33)

到目前为止,我的理解是降级 MongoDb 以避免异常。但考虑到其他依赖项,我必须使用最新版本。如果我错了,请纠正我并建议我需要查看的步骤。

4

0 回答 0