unauthorized - com.mongodb.MongoQueryException: Query failed with error code 13 -


we getting com.mongodb.mongoqueryexception:

> query failed error code 13 while connecting mongdb trhough > spring-data.   mongodb version 3.x 

spring 4.1.6, mongo-java-driver - 3.0.2, spring-data-commons - 1.10.0.release, spring-data-mongodb - 1.7.0.release

unable run find query on collection.

i able view collection on gui using same credentials.

any appreciated.

here full exception:

> org.springframework.data.mongodb.uncategorizedmongodbexception: query > failed error code 13 , error message 'not authorized query > on <db.table>' on server xxx; nested exception > com.mongodb.mongoqueryexception: query failed error code 13 , > error message 'not authorized query on db.table on server xxx >     @ org.springframework.data.mongodb.core.mongoexceptiontranslator.translateexceptionifpossible(mongoexceptiontranslator.java:96) >     @ org.springframework.data.mongodb.core.mongotemplate.potentiallyconvertruntimeexception(mongotemplate.java:2002) >     @ org.springframework.data.mongodb.core.mongotemplate.executefindmultiinternal(mongotemplate.java:1885) 

check mongo xsd 2.6 vs 3.0 java drivers, different - seems still use old way authenticate.

<mongo:db-factory dbname="${mongo.database}" username="${mongo.user}"                   password="${mongo.pwd}" mongo-ref="mongo"/> 

this works 2.6 java driver only, not 3.0 java driver.

use mongo-client-option credentials attribute.

<mongo:mongo-client replica-set="${mongo.replica-set}" credentials="you need put here user/password specific db"> 

the comma delimited list of username:password@database entries use authentication. appending ? uri.authmechanism allows specify authentication challenge mechanism. if credential you're trying pass contains comma itself, quote single quotes: '…'.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -