Jump to content
Changes to the Jaspersoft community edition download ×

Connection to MongoDB using JasperStudio & IReport


Recommended Posts

Hello,

I'm trying to make connection to MongoDb from JasperStudio without success.
The same identical connection used into IReport works nice.
I'm really confused because I don't know what I would change.

This is the error log but not being a programmers i don't understand almost nothing.  The URI, User, Password are obviously correct.

net.sf.jasperreports.engine.JRException: Error creating MongoDBConnection; Caused by: Cannot test MongoDB connection; Caused by: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='t4h', source='T4H-sample', password=<hidden>, mechanismProperties={}}
    at com.jaspersoft.mongodb.connection.MongoDbConnection.<init>(MongoDbConnection.java:86)
    at com.jaspersoft.mongodb.adapter.MongoDbDataAdapterService.createConnection(MongoDbDataAdapterService.java:70)
    at com.jaspersoft.mongodb.adapter.MongoDbDataAdapterService.test(MongoDbDataAdapterService.java:91)
    at com.jaspersoft.studio.data.wizard.AbstractDataAdapterWizard$3.runOperations(AbstractDataAdapterWizard.java:153)
    at com.jaspersoft.studio.utils.jobs.CheckedRunnableWithProgress$1.run(CheckedRunnableWithProgress.java:50)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: net.sf.jasperreports.engine.JRException: Cannot test MongoDB connection; Caused by: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='t4h', source='T4H-sample', password=<hidden>, mechanismProperties={}}
    at com.jaspersoft.mongodb.connection.MongoDbConnection.test(MongoDbConnection.java:192)
    at com.jaspersoft.mongodb.connection.MongoDbConnection.<init>(MongoDbConnection.java:82)
    ... 5 more
Caused by: com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='t4h', source='T4H-sample', password=<hidden>, mechanismProperties={}}
    at com.mongodb.internal.connection.SaslAuthenticator.wrapException(SaslAuthenticator.java:173)
    at com.mongodb.internal.connection.SaslAuthenticator.access$300(SaslAuthenticator.java:40)
    at com.mongodb.internal.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:70)
    at com.mongodb.internal.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:47)
    at com.mongodb.internal.connection.SaslAuthenticator.doAsSubject(SaslAuthenticator.java:179)
    at com.mongodb.internal.connection.SaslAuthenticator.authenticate(SaslAuthenticator.java:47)
    at com.mongodb.internal.connection.InternalStreamConnectionInitializer.authenticateAll(InternalStreamConnectionInitializer.java:152)
    at com.mongodb.internal.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:63)
    at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:127)
    at com.mongodb.internal.connection.UsageTrackingInternalConnection.open(UsageTrackingInternalConnection.java:50)
    at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.open(DefaultConnectionPool.java:390)
    at com.mongodb.internal.connection.DefaultConnectionPool.get(DefaultConnectionPool.java:106)
    at com.mongodb.internal.connection.DefaultConnectionPool.get(DefaultConnectionPool.java:92)
    at com.mongodb.internal.connection.DefaultServer.getConnection(DefaultServer.java:85)
    at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.getConnection(ClusterBinding.java:115)
    at com.mongodb.client.internal.ClientSessionBinding$SessionBindingConnectionSource.getConnection(ClientSessionBinding.java:111)
    at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:212)
    at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:206)
    at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:116)
    at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:109)
    at com.mongodb.operation.CommandReadOperation.execute(CommandReadOperation.java:56)
    at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:179)
    at com.mongodb.client.internal.MongoDatabaseImpl.executeCommand(MongoDatabaseImpl.java:184)
    at com.mongodb.client.internal.MongoDatabaseImpl.runCommand(MongoDatabaseImpl.java:153)
    at com.mongodb.client.internal.MongoDatabaseImpl.runCommand(MongoDatabaseImpl.java:148)
    at com.mongodb.client.internal.MongoDatabaseImpl.runCommand(MongoDatabaseImpl.java:138)
    at com.jaspersoft.mongodb.connection.MongoDbConnection.test(MongoDbConnection.java:187)
    ... 6 more
Caused by: com.mongodb.MongoCommandException: Command failed with error 18 (AuthenticationFailed): 'Authentication failed.' on server 10.18.192.88:27021. The full response is {"operationTime": {"$timestamp": {"t": 1686039755, "i": 1}}, "ok": 0.0, "errmsg": "Authentication failed.", "code": 18, "codeName": "AuthenticationFailed", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1686039755, "i": 1}}, "signature": {"hash": {"$binary": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "$type": "00"}, "keyId": {"$numberLong": "0"}}}}
    at com.mongodb.internal.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:179)
    at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:299)
    at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:255)
    at com.mongodb.internal.connection.CommandHelper.sendAndReceive(CommandHelper.java:83)
    at com.mongodb.internal.connection.CommandHelper.executeCommand(CommandHelper.java:33)
    at com.mongodb.internal.connection.SaslAuthenticator.sendSaslStart(SaslAuthenticator.java:130)
    at com.mongodb.internal.connection.SaslAuthenticator.access$100(SaslAuthenticator.java:40)
    at com.mongodb.internal.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:54)
    ... 30 more
 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic


Hello,

Looking at final caused by error message it seems that, connection is failed because authentication failure with error code 18.

Kindly check connection string configured.

Command failed with error 18 (AuthenticationFailed): 'Authentication failed.' on server 10.18.192.88:27021. The full response is {"operationTime": {"$timestamp": {"t": 1686039755, "i": 1}}, "ok": 0.0, "errmsg": "Authentication failed.", "code": 18,

We tried to search over internet about this code and found some of the URL where similar error listed.
Kindly have a look at below suggested resolution.

https://howtodoinjava.com/mongodb/command-failed-with-error-18/
https://www.mongodb.com/community/forums/t/mongosecurityexception-exception-authenticating-mongocredential/106790
https://www.mongodb.com/community/forums/t/mongodb-replicaset-error-authenticationfailed-code-18/205762/4

Hope this will help you !!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...