2

我正在尝试将 Jaspersoft Studio 6.2.0 连接到 MongoLab 上托管的 MongoDB 数据库(mongod 版本:3.0.7)。

使用连接 URI:

 mongodb://ds012345-a0.mongolab.com:12345,ds012345-a1.mongolab.com:12345/mydb?replicaSet=rs-ds012345

在此处输入图像描述

测试适配器时出现以下异常:

net.sf.jasperreports.engine.JRException: com.mongodb.CommandFailureException: { "serverUsed" : "ds012345-a0.mongolab.com:12345" , "ok" : 0.0 , "errmsg" : "auth failed" , "code" : 18}
    at com.jaspersoft.mongodb.connection.MongoDbConnection.test(MongoDbConnection.java:162)
    at com.jaspersoft.mongodb.adapter.MongoDbDataAdapterService.test(MongoDbDataAdapterService.java:93)
    at com.jaspersoft.studio.data.wizard.AbstractDataAdapterWizard$3.runOperations(AbstractDataAdapterWizard.java:162)
    at com.jaspersoft.studio.utils.jobs.CheckedRunnableWithProgress$1.run(CheckedRunnableWithProgress.java:59)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.mongodb.CommandFailureException: { "serverUsed" : "ds012345-a0.mongolab.com:12345" , "ok" : 0.0 , "errmsg" : "auth failed" , "code" : 18}
    at com.mongodb.CommandResult.getException(CommandResult.java:76)
    at com.mongodb.CommandResult.throwOnError(CommandResult.java:131)
    at com.mongodb.DBPort$NativeAuthenticator.authenticate(DBPort.java:652)
    at com.mongodb.DBPort.authenticate(DBPort.java:364)
    at com.mongodb.DBPort.checkAuth(DBPort.java:375)
    at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:291)
    at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:271)
    at com.mongodb.DBCollectionImpl.find(DBCollectionImpl.java:84)
    at com.mongodb.DB.command(DB.java:317)
    at com.mongodb.DB.command(DB.java:296)
    at com.mongodb.DB.command(DB.java:371)
    at com.mongodb.DB.command(DB.java:243)
    at com.mongodb.DB.command(DB.java:397)
    at com.jaspersoft.mongodb.connection.MongoDbConnection.test(MongoDbConnection.java:158)
    ... 4 more
4

1 回答 1

3

问题在于MongoDB 3.0 版中添加的SCRAM-SHA-1身份验证机制。

如本JasperReports Server 问题中所述,解决方案是通过替换文件来更新 MongoDB Java 驱动程序:

Jaspersoft Studio-6.2.0.final\configuration\org.eclipse.osgi\29\0\.cp\lib\mongo-java-driver-2.12.3.jar

在这里找到一个:https ://github.com/mongodb/mongo-java-driver/releases/download/r2.13.2/mongo-java-driver-2.13.2.jar

使用 URI 中的凭据,连接成功。

于 2015-12-03T11:23:35.333 回答