Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3424

¿Puedo conectar una aplicación a mongodb con authenticación SCRAM-SHA256?

    • Type: Icon: Task Task
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.11.0
    • Component/s: API
    • None
    • Environment:
      Implementando aplicación nativa de android (java) con driver org.mongodb:mongodb-driver:3.11.0

      Estoy intentando conectarme con a mi servidor mongo (MongoClient) con autenticación de SCRAM-SHA256 (createScramSha256Credential), pero marca una excepción:

      E/com.probando.app.MongoDB: MongoException ->
      com.mongodb.MongoException: java.lang.NoClassDefFoundError: com.mongodb.internal.connection.ScramShaAuthenticator$ScramShaSaslClient
      at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:138)
      at com.mongodb.internal.connection.UsageTrackingInternalConnection.open(UsageTrackingInternalConnection.java:50)
      at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.open(DefaultConnectionPool.java:398)
      at com.mongodb.internal.connection.DefaultConnectionPool.get(DefaultConnectionPool.java:115)
      at com.mongodb.internal.connection.DefaultConnectionPool.get(DefaultConnectionPool.java:101)
      at com.mongodb.internal.connection.DefaultServer.getConnection(DefaultServer.java:92)
      at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.getConnection(ClusterBinding.java:126)
      at com.mongodb.operation.FindOperation$1.call(FindOperation.java:728)
      at com.mongodb.operation.FindOperation$1.call(FindOperation.java:725)
      at com.mongodb.operation.OperationHelper.withReadConnectionSource(OperationHelper.java:463)
      at com.mongodb.operation.FindOperation.execute(FindOperation.java:725)
      at com.mongodb.operation.FindOperation.execute(FindOperation.java:89)
      at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:189)
      at com.mongodb.client.internal.MongoIterableImpl.execute(MongoIterableImpl.java:143)
      at com.mongodb.client.internal.MongoIterableImpl.iterator(MongoIterableImpl.java:92)
      at com.mongodb.client.internal.MongoIterableImpl.forEach(MongoIterableImpl.java:121)
      at com.mongodb.client.internal.MongoIterableImpl.into(MongoIterableImpl.java:133)
      at com.probando.app.MongoDB.GetDocumentos(MongoDB.java:129)
      at com.probando.app.MongoActivity$GetDocumentos.doInBackground(MongoActivity.java:58)
      at com.probando.app.MongoActivity$GetDocumentos.doInBackground(MongoActivity.java:54)
      at android.os.AsyncTask$2.call(AsyncTask.java:288)
      at java.util.concurrent.FutureTask.run(FutureTask.java:237)
      at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
      at java.lang.Thread.run(Thread.java:818)
      Caused by: java.lang.NoClassDefFoundError: com.mongodb.internal.connection.ScramShaAuthenticator$ScramShaSaslClient
      at com.mongodb.internal.connection.ScramShaAuthenticator.createSaslClient(ScramShaAuthenticator.java:77)
      at com.mongodb.internal.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:50)
      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:156)
      at com.mongodb.internal.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:63)
      at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:129)
      at com.mongodb.internal.connection.UsageTrackingInternalConnection.open(UsageTrackingInternalConnection.java:50) 
      at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.open(DefaultConnectionPool.java:398) 
      at com.mongodb.internal.connection.DefaultConnectionPool.get(DefaultConnectionPool.java:115) 
      at com.mongodb.internal.connection.DefaultConnectionPool.get(DefaultConnectionPool.java:101) 
      at com.mongodb.internal.connection.DefaultServer.getConnection(DefaultServer.java:92) 
      at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.getConnection(ClusterBinding.java:126) 
      at com.mongodb.operation.FindOperation$1.call(FindOperation.java:728) 
      at com.mongodb.operation.FindOperation$1.call(FindOperation.java:725) 
      at com.mongodb.operation.OperationHelper.withReadConnectionSource(OperationHelper.java:463) 
      at com.mongodb.operation.FindOperation.execute(FindOperation.java:725) 
      at com.mongodb.operation.FindOperation.execute(FindOperation.java:89) 
      at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:189) 
      at com.mongodb.client.internal.MongoIterableImpl.execute(MongoIterableImpl.java:143) 
      at com.mongodb.client.internal.MongoIterableImpl.iterator(MongoIterableImpl.java:92) 
      at com.mongodb.client.internal.MongoIterableImpl.forEach(MongoIterableImpl.java:121) 
      at com.mongodb.client.internal.MongoIterableImpl.into(MongoIterableImpl.java:133) 
      at com.probando.app.MongoDB.GetDocumentos(MongoDB.java:129) 
      at com.probando.app.MongoActivity$GetDocumentos.doInBackground(MongoActivity.java:58) 
      at com.probando.app.MongoActivity$GetDocumentos.doInBackground(MongoActivity.java:54) 
      at android.os.AsyncTask$2.call(AsyncTask.java:288) 
      at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
      at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
      at java.lang.Thread.run(Thread.java:818) 
      I/cluster: Cluster created with settings

      {hosts=[mongo.crmex.finconfia.com.mx:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}

       

       

      Pero el error ocurre cuando intento hacer una búsqueda en mi colección, lo cual no entiendo porque y antes de mostrar el error me marca que la conexión se establecio (por o que entiendo):

      I/cluster: Monitor thread successfully connected to server with description ServerDescription{address=myserver.com:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion

      {versionList=[4, 0, 9]}

      , minWireVersion=0, maxWireVersion=7, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=76710156}
      I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mongodb.internal.connection.ScramShaAuthenticator$ScramShaSaslClient>
      I/connection: Closed connection [connectionId

      {localValue:2}

      ] to myserver.com:27017 because there was a socket exception raised by this connection.

            Assignee:
            Unassigned Unassigned
            Reporter:
            johana.reza.25@gmail.com Johana Reza
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: