2

I am getting following error while trying to find records from mongodb collection.

org.springframework.data.mongodb.UncategorizedMongoDbException: Query failed with error code 13 and error message 'not authorized for query on ssprod.logger_user_activities' on server beta.redbus.co:27017; nested exception is com.mongodb.MongoQueryException: Query failed with error code 13 and error message 'not authorized for query on ssprod.logger_user_activities' on server beta.redbus.co:27017
    at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:96)
    at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2011)
    at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1894)
    at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1705)
    at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1688)
    at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:601)
    at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.findAll(SimpleMongoRepository.java:268)
    at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.findAll(SimpleMongoRepository.java:193)
    at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.findAll(SimpleMongoRepository.java:47)

my spring configuration file looks like below

     <mongo:repositories
              base-package="psl.service.infra.loggerx.server" mongo-template-ref="mongoTemplate"/>

<bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean">
    <property name="host" value="${mongo.host}"/>
  </bean>

      <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
        <constructor-arg ref="mongo"/>
        <constructor-arg name="databaseName" value="ssprod"/>
        <constructor-arg name="userCredentials" ref="mongoCredentials"/>
      </bean>

      <bean id="mongoCredentials" class="org.springframework.data.authentication.UserCredentials">
        <constructor-arg name="username" value="${mongo.username}"/>
        <constructor-arg name="password" value="${mongo.password}" />
      </bean>



    </beans>

Credentials are correct and user has read and write access.Kindly help.

2
  • Has your issue resolved? Just wondering whether the below solution helped or you are still facing any issue? Commented Aug 3, 2016 at 11:43
  • Ya issue got resolved. actually in my pom.xml there was some conflict between mongo jars. Commented Sep 5, 2016 at 7:32

1 Answer 1

2

I think the problem is that the "AuthenticationMechanism" (i.e. value is SCRAM-SHA-1) is missing in the Spring context. Please refer the below link and change the Spring context file accordingly.

Even after changing the context if you get this error, please paste the error with the latest context file.

Refer this link

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.