Announcement Announcement Module
Collapse
No announcement yet.
can't authenticate twice on same database Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • can't authenticate twice on same database

    regarding mongodb

    Getting exception

    Code:
    java.lang.IllegalStateException: can't authenticate twice on the same database
    	at com.mongodb.DB.authenticate(DB.java:565)
    	at org.springframework.data.mongodb.core.MongoDbUtils.doGetDB(MongoDbUtils.java:113)
    	at org.springframework.data.mongodb.core.MongoDbUtils.getDB(MongoDbUtils.java:75)
    when trying to authenticate to auth enabled mongodb

    related xml
    Code:
    	<mongo:mongo id="mongodb" host="192.168.1.8" port="27017">
    	</mongo:mongo>
    
    	<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
    	   <constructor-arg ref="mongodb"/>
    	   <constructor-arg name="databaseName" value="test-1"/>
    	  <constructor-arg name="userCredentials" ref="userCredentials"/>
    	</bean>
    	
    	<bean id="userCredentials" class="org.springframework.data.authentication.UserCredentials">
    	 	<constructor-arg name="username" value="usm"/>
    	  <constructor-arg name="password" value="pwd"/>
        </bean>
    application is multi-threaded, with multiple threads all inserting to mongodb at once. The first couple of threads succeed, insert their rows, and terminate.

    Am I doing this wrong, is this a bug?
    Last edited by kochcp; Nov 30th, 2012, 09:24 AM.

  • #2
    Which version of Spring Data MongoDB are you using?

    Comment


    • #3
      I have:

      spring-data-mongodb-1.1.0.RELEASE
      spring-data-cross-store-1.1.0.RELEASE
      spring-data-log4j-1.1.0.RELEASE

      spring-data-commons-core-1.4.0.RC1

      mongo driver 2.10.0

      Comment


      • #4
        It seems our synchonization range is too small as it doesn't include the !db.isAuthenticated() call, so two threads might run into the authentication block. Would you mind opening a ticket in our JIRA? I'm happy to include the fix in the next bug fix release then.

        Comment


        • #5
          https://jira.springsource.org/browse/DATAMONGO-585

          thanks.

          Comment

          Working...
          X