Quantcast
Channel: Spring Community Forums - NoSQL
Viewing all articles
Browse latest Browse all 128

can't authenticate twice on same database

$
0
0
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?

Viewing all articles
Browse latest Browse all 128

Trending Articles