Announcement Announcement Module
Collapse
No announcement yet.
spring-mongodb-rc1 bug Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring-mongodb-rc1 bug

    define:mongoTemplate
    <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.Mongo Template">
    <constructor-arg ref="mongoDbFactory"/>
    </bean>

    define:bean
    @Document
    public class CacheVersion {

    @Id
    private String className;

    @Indexed
    private long version;
    .....(get/set)
    }

    method:
    mongoTemplate.findById("className", CacheVersion.class);

    code abover test ok in spring-data-mongodb-1.0.0.M5

    today i update spring-data-mongodb get latest to mvn spring-data-mongodb-1.0RC1-shotsnap.jar

    mongoTemplate.findById("className", CacheVersion.class);(error here)
    Code:
    org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type java.math.BigInteger for value 'apps.mforum.domain.User'; nested exception is java.lang.NumberFormatException: For input string: "apps."
    	at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41)
    	at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:170)
    	at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:154)
    	at org.springframework.data.mongodb.core.convert.MappingMongoConverter.getPotentiallyConvertedSimpleWrite(MappingMongoConverter.java:604)
    	at org.springframework.data.mongodb.core.convert.MappingMongoConverter.convertToMongoType(MappingMongoConverter.java:817)
    	at org.springframework.data.mongodb.core.QueryMapper.convertId(QueryMapper.java:130)
    Caused by: java.lang.NumberFormatException: For input string: "apps."
    	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    	at java.lang.Integer.parseInt(Integer.java:449)
    	at java.math.BigInteger.<init>(BigInteger.java:316)
    	at java.math.BigInteger.<init>(BigInteger.java:451)
    	at org.springframework.data.mongodb.core.convert.MongoConverters$StringToBigIntegerConverter.convert(MongoConverters.java:119)
    	at org.springframework.data.mongodb.core.convert.MongoConverters$StringToBigIntegerConverter.convert(MongoConverters.java:115)
    	at org.springframework.core.convert.support.GenericConversionService$ConverterAdapter.convert(GenericConversionService.java:511)
    	at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:35)
    	... 41 more
    Last edited by jusescn; Dec 7th, 2011, 07:37 PM.

  • #2
    What version are you referring to? There's no 1.0RC1-shotsnap . We haven't even officially released RC1 yet. So what version combination of SD Commons and SD MongoDB are you using? Are you registering custom converters?

    PS: Please use [ code ] tags for stacktraces.

    Comment


    • #3
      sorry. it is spring-mongodb-1.0.0.BUILD-SNAPSHOT.jar,it is not officially released !I download spring-mongodb latest code from git and mvn to get spring-mongodb-1.0.0.BUILD-SNAPSHOT.jar (git log message:* DATAMONGO-340 - Prepare 1.0.0.BUILD-SNAPSHOT.
      ).

      I use spring-data-commons-core-1.2.0.M2.jar and mongo-2.7.2.jar and do not registering custom converters!

      my test code work well while use spring-data-mongodb-1.0.0.M5.jar.

      but use spring-mongodb-1.0.0.BUILD-SNAPSHOT.jar , it error :mongoTemplate.findById("className", CacheVersion.class);

      Comment


      • #4
        Similar error.

        Normal String field tried to be converted to BigInteger.

        Version 1.0.0.RC1

        Code:
        org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type java.math.BigInteger for value 'KKaK'; nested exception is java.lang.NumberFormatException: For input string: "KKaK"
        	at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41)
        	at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:170)
        	at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:154)
        	at org.springframework.data.mongodb.core.convert.MappingMongoConverter.getPotentiallyConvertedSimpleWrite(MappingMongoConverter.java:604)
        	at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeSimpleInternal(MappingMongoConverter.java:585)
        	at org.springframework.data.mongodb.core.convert.MappingMongoConverter.access$100(MappingMongoConverter.java:73)
        	at org.springframework.data.mongodb.core.convert.MappingMongoConverter$4.doWithPersistentProperty(MappingMongoConverter.java:370)
        	at org.springframework.data.mongodb.core.convert.MappingMongoConverter$4.doWithPersistentProperty(MappingMongoConverter.java:357)
        	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:173)
        	at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:357)
        	at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:329)
        	at org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:294)
        	at org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:73)
        	at org.springframework.data.mongodb.core.MongoTemplate.doInsert(MongoTemplate.java:615)
        	at org.springframework.data.mongodb.core.MongoTemplate.insert(MongoTemplate.java:577)
        	at org.springframework.data.mongodb.core.MongoTemplate.insert(MongoTemplate.java:568)

        Comment


        • #5
          I have the same question.

          my project is run well in Spring data mongo M5.

          I update the spring data mongodb to RC1 use the spring official dependency.

          here is the console log

          Failed to convert from type java.lang.String to type java.math.BigInteger for value 'zhushen'; nested exception is java.lang.NumberFormatException: For input string: "zhushen"

          my field is String ,Spring want to convert it to BigInteger ,why?

          Comment


          • #6
            I find the solution.....

            update your Spring Data Commons to 1.2.0.RC1


            <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-commons-core</artifactId>
            <version>1.2.0.RC1</version>
            </dependency>

            Comment

            Working...
            X