Jaspersoft Studio MongoDB连接身份验证失败

时间:2015-12-02 11:45:05

标签: mongodb mlab jaspersoft-studio

我试图将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

enter image description here

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

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

1 个答案:

答案 0 :(得分:2)

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

正如本JasperReports Server issue所述,解决方案是通过替换文件来更新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中的凭据,连接成功。