[JAVA-2119] Query failed with error code 13 and error message 'not authorized for query Created: 23/Feb/16  Updated: 11/Sep/19  Resolved: 11/Mar/16

Status: Closed
Project: Java Driver
Component/s: Configuration
Affects Version/s: 3.2.0
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Prakash Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Window 7, JDK 1.7



 Description   

Hi Team,

we are facing below issue

Query failed with error code 13 and error message 'not authorized for query dbname.collectionName.

We checked using No Sql Manager and have correct privileges on collection.

Below are POM.XML

<!-- Spring Data MongoDB -->
	<dependency>
			<groupId>org.springframework.data</groupId>
			<artifactId>spring-data-mongodb</artifactId>
			<version>1.7.0.RELEASE</version>
			<type>jar</type>
			<scope>compile</scope>
		</dependency> 
		<!-- MongoDB Java Driver -->
		<dependency>
			<groupId>org.mongodb</groupId>
			<artifactId>mongo-java-driver</artifactId>
			<version>3.2.0</version>
			<type>jar</type>
			<scope>compile</scope>
		</dependency>

We are using Spring Version - 4.0.1 Release.

Driver Connection Configuration

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:task="http://www.springframework.org/schema/task"
       xmlns:mongo="http://www.springframework.org/schema/data/mongo"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/data/mongo
       http://www.springframework.org/schema/data/mongo/spring-mongo-1.8.xsd  
       http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd   
       http://www.springframework.org/schema/task
       http://www.springframework.org/schema/task/spring-task-3.0.xsd">
 
	<bean id="mdbProperties"
		class="org.springframework.beans.factory.config.PropertiesFactoryBean">
 
		<!-- <property name="location" value="WEB-INF/spring-data.properties" /> -->
		<property name="locations">
			<list>
				<value>WEB-INF/mdb-data-local.properties</value>
			</list>
		</property>
	</bean>
	<context:property-placeholder
		properties-ref="mdbProperties" ignore-resource-not-found="true" />
 
	<mongo:mongo-client id="mongo" replica-set="${mdb.replica_set}">
		<mongo:client-options connections-per-host="100"
			threads-allowed-to-block-for-connection-multiplier="10"
			connect-timeout="5000" max-wait-time="600000"
			max-connection-idle-time="600000" write-concern="JOURNAL_SAFE"
			read-preference="PRIMARY" />
	</mongo:mongo-client>
 
	<bean id="mongoCredentials" class="com.cisco.ccw.oo.utility.UserCredentials">
		<constructor-arg name="username" value="${mdb.username}" />
		<constructor-arg name="password" value="${mdb.password}" />
	</bean>
 
	<bean id="mongoDbFactory"
		class="org.springframework.data.mongodb.core.SimpleMongoDbFactory">
		<constructor-arg name="mongo" ref="mongo" />
		<constructor-arg name="databaseName" value="${mdb.dbname}" />
		<constructor-arg name="credentials" ref="mongoCredentials" />
	</bean>
	<!-- <mongo:db-factory dbname="${mdb.dbname}" mongo-ref="mongo" username="${mdb.username}" 
		password="${mdb.password}" /> -->
 
 
	<mongo:mapping-converter id="mappingConverter">
		<mongo:custom-converters>
			<mongo:converter>
				<bean class="com.cisco.ccw.oo.utility.BigDecimalReadConverter" />
			</mongo:converter>
			<mongo:converter>
				<bean class="com.cisco.ccw.oo.utility.BigDecimalWriteConverter" />
			</mongo:converter>
			<mongo:converter>
				<bean class="com.cisco.ccw.oo.utility.DateTimeWriteConverter" />
			</mongo:converter>
		</mongo:custom-converters>
	</mongo:mapping-converter>
 
 
 
	<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
		<constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
		<constructor-arg name="mongoConverter" ref="mappingConverter" />
	</bean>
</beans>



 Comments   
Comment by Joanna Cheng [ 11/Mar/16 ]

Hi Prakash,

As I haven't heard back, I will assume this is not part of a supported project, and that you are not interested in a support subscription. As such I will close out this ticket now.

Kind regards,
Joanna

Comment by Joanna Cheng [ 24/Feb/16 ]

Hi Prakash,

The JAVA project is for reporting bugs and feature requests with the Java driver. From the description, it looks like you need assistance with correctly configuring Spring with the right credentials for connection to MongoDB.

We can help you with this if you have a valid support subscription; is this question part of a project that already has a support subscription with us? You do not appear to be in any groups that hold a valid support subscription, but if you should be a member of one of those groups, please ask your colleagues to open a ticket and request you be added to the group.

Please also let me know if you would be interested in a support subscription, if so I can have an Account Executive contact you to discuss further.

Otherwise, the appropriate community forum for issues with the MongoDB server is the mongodb-user Google Group or Stack Overflow. Public discussion there can help others learn and resolve similar issues.

Let me know if you have any questions about the above.

Kind regards,
Joanna

Generated at Thu Feb 08 08:56:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.