Results 1 to 7 of 7

Thread: Credentials issue in 1.1.1.RELEASE

  1. #1
    Join Date
    Feb 2013
    Posts
    4

    Default Credentials issue in 1.1.1.RELEASE

    Hi all,

    I'm afraid I'm rather new to Spring and MongoDB, but I've been working from the mongodb.examples.hello project, and when I change the dependency in the pom to 1.1.1.RELEASE I get and exception as follows:
    Code:
    java.lang.NoSuchMethodError: org.springframework.data.authentication.UserCredentials.hasUsername()Z
    	at org.springframework.data.mongodb.core.MongoDbUtils.doGetDB(MongoDbUtils.java:105)
    	at org.springframework.data.mongodb.core.MongoDbUtils.getDB(MongoDbUtils.java:75)
    	at org.springframework.data.mongodb.core.SimpleMongoDbFactory.getDb(SimpleMongoDbFactory.java:118
    I have added credentials to the
    Code:
    mongo:db-factory
    tag in the -context.xml, which if I don't do I get a "NO_CREDENTIALS" message:

    Code:
    Caused by: java.lang.NoSuchFieldError: NO_CREDENTIALS
    	at org.springframework.data.mongodb.core.SimpleMongoDbFactory.<init>(SimpleMongoDbFactory.java:53)
    What I can't fathom is: is this an issue with the 1.1.1.RELEASE build, or am I missing some config, or other information that could resolve this issue?

    Any advice or help of any kind would be greatly appreciated, and if I can provide any more information to make that easier, I'll do my best.

    Cheers all,

    Rob

  2. #2
    Join Date
    Apr 2006
    Location
    Dresden, Germany
    Posts
    493

    Default

    Depending on which version you're coming from you might need to upgrade Spring Data Commons alongside. It's usually best not to declare the dependency to Spring Data Commons explicitly at all as store module upgrades pull in the required version of it transitively.

    Current SD MongoDB version is 1.2 using SD Commons 1.5. So if you want the latest and greatest, try these .

  3. #3
    Join Date
    Feb 2013
    Posts
    4

    Default

    Hi Oliver,

    Thanks for the response! I've changed up to spring-data-mongodb 1.2.0.RELEASE, which seems to pull in the Spring Data Commons dependency (unless something else does) which is at 1.5.0.RELEASE, but I'm still getting an exception:

    java.lang.NoSuchMethodError: org.springframework.data.authentication.UserCreden tials.hasUsername()Z
    at org.springframework.data.mongodb.core.MongoDbUtils .doGetDB(MongoDbUtils.java:105)
    at org.springframework.data.mongodb.core.MongoDbUtils .getDB(MongoDbUtils.java:75)
    at org.springframework.data.mongodb.core.SimpleMongoD bFactory.getDb(SimpleMongoDbFactory.java:118)
    at org.springframework.data.mongodb.core.SimpleMongoD bFactory.getDb(SimpleMongoDbFactory.java:107)


    The only place I'm currently setting credentials is in the test context bean definitions:

    <mongo:db-factory id="mongoDbFactory"
    username="user"
    password="password1"
    dbname="testdb"/>
    <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.Mongo Template">
    <constructor-arg ref="mongoDbFactory"/>
    </bean>


    As I say, version 1.0.0.M4 of spring-data-mongodb works just fine... but not later versions.

    Thanks for your help

  4. #4
    Join Date
    Apr 2006
    Location
    Dresden, Germany
    Posts
    493

    Default

    Can you please post the output of mvn dependency:tree?

  5. #5
    Join Date
    Feb 2013
    Posts
    4

    Default


    [INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ trainee-developer-programme ---
    [INFO] com.XXX.tdp:trainee-developer-programme:jar:0.0.1-SNAPSHOT
    [INFO] +- junit:junit:jar:4.8.1:test
    [INFO] +- log4j:log4j:jar:1.2.16:compile
    [INFO] +- org.slf4j:slf4j-api:jar:1.6.1:compile
    [INFO] +- org.slf4j:jcl-over-slf4j:jar:1.6.1:compile
    [INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.1:compile
    [INFO] +- org.springframework:spring-core:jar:3.1.0.RELEASE:compile
    [INFO] | \- org.springframework:spring-asm:jar:3.1.0.RELEASE:compile
    [INFO] +- org.springframework:spring-test:jar:3.1.0.RELEASE:test
    [INFO] +- org.springframework:spring-context:jar:3.1.0.RELEASE:compile
    [INFO] | +- org.springframework:spring-beans:jar:3.1.0.RELEASE:compile
    [INFO] | \- org.springframework:spring-expression:jar:3.1.0.RELEASE:compile
    [INFO] +- org.springframework:spring-aop:jar:3.1.0.RELEASE:compile
    [INFO] | \- aopalliance:aopalliance:jar:1.0:compile
    [INFO] +- cglib:cglib:jar:2.2:compile
    [INFO] | \- asm:asm:jar:3.1:compile
    [INFO] \- org.springframework.data:spring-data-mongodb:jar:1.2.0.RELEASE:compile
    [INFO] +- org.springframework:spring-tx:jar:3.1.4.RELEASE:compile
    [INFO] +- org.springframework.data:spring-data-commons:jar:1.5.0.RELEASE:compile
    [INFO] \- org.mongodb:mongo-java-driver:jar:2.10.1:compile

  6. #6
    Join Date
    Apr 2006
    Location
    Dresden, Germany
    Posts
    493

    Default

    That looks correct. The SD COmmons version you listed here definitely contains the UserCredentials type with the relevant methods. Is this a web project maybe that has some legacy JARs left in its WEB-INF/lib folder or the like? Make sure you run mvn clean before re-trying or clear out the project deployment into your Tomcat in case you're working with Eclipse WTP.

  7. #7
    Join Date
    Feb 2013
    Posts
    4

    Default

    I've got this fixed now, the clean install worked fine, but running through the IDE was failing, it seems IntelliJ was clinging to an old reference of the commons library. Deleted it and reimported the dependencies and all works fine now. Thanks for your help!

    Rob

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •