Announcement Announcement Module
Collapse
No announcement yet.
Spring Data MongoDB 1.0.0.M2 ->1.0.0. M3 Upgrading Issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Data MongoDB 1.0.0.M2 ->1.0.0. M3 Upgrading Issue

    Hi I just upgraded my project's Spring Data MongoDB to from 1.0.0.M2 to 1.0.0.M3, I had no problems with parameter order and configuration changes, but one of my entity got a strange problem. Something related to BigDecimal (this entity has a lot of BigDecimal columns)


    Here is a snippet of my stack trace:
    Code:
    2011-06-07 17:37:12,906 [main] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'auditTrailRepositoryImpl': Injection of autowired dependencies failed; n
    ested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.data.document.mongodb.repository.Mongo
    Repository com.djavafactory.pttech.rrm.mongorepository.AuditTrailRepositoryImpl.auditTrailRepository; nested exception is org.springframework.beans.factory.Bean
    CreationException: Error creating bean with name 'reportRepositoryImpl': Injection of autowired dependencies failed; nested exception is org.springframework.bea
    ns.factory.BeanCreationException: Could not autowire field: org.springframework.data.document.mongodb.repository.MongoRepository com.djavafactory.pttech.rrm.mon
    gorepository.ReportRepositoryImpl.reportRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '
    reportRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Multiple constructors with arguments
    found in class java.math.BigDecimal! Annotate one with @PreferedConstructor explicitly to select it to be used in persistence operations.
            at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java
    :285)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
            at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
            at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
            at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
            at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
            at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
            at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
            at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
            at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
            at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
            at org.apache.catalina.startup.Embedded.start(Embedded.java:825)
            at org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMojo.java:558)
            at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java:255)
            at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
            at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
            at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
            at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
            at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
            at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
            at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
    Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.data.document.mongodb.repository.MongoReposito
    ry com.djavafactory.pttech.rrm.mongorepository.AuditTrailRepositoryImpl.auditTrailRepository; nested exception is org.springframework.beans.factory.BeanCreation
    Exception: Error creating bean with name 'reportRepositoryImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.facto
    ry.BeanCreationException: Could not autowire field: org.springframework.data.document.mongodb.repository.MongoRepository com.djavafactory.pttech.rrm.mongoreposi
    tory.ReportRepositoryImpl.reportRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reportRe
    pository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Multiple constructors with arguments found in
     class java.math.BigDecimal! Annotate one with @PreferedConstructor explicitly to select it to be used in persistence operations.
            at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.j
    ava:502)
            at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
            at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java
    :282)
            ... 41 more
    I'm tracking down the problem right now as I didn't get this error with 1.0.0.M2, if any of you has any clue please let me know...

    Thanks in advance.

  • #2
    Snippet part. 2:
    Code:
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reportRepositoryImpl': Injection of autowired dependencies fa
    iled; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.data.document.mongodb.repositor
    y.MongoRepository com.djavafactory.pttech.rrm.mongorepository.ReportRepositoryImpl.reportRepository; nested exception is org.springframework.beans.factory.BeanC
    reationException: Error creating bean with name 'reportRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumen
    tException: Multiple constructors with arguments found in class java.math.BigDecimal! Annotate one with @PreferedConstructor explicitly to select it to be used
    in persistence operations.
            at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java
    :285)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:844)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
            at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.j
    ava:474)
            ... 43 more
    Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.data.document.mongodb.repository.MongoReposito
    ry com.djavafactory.pttech.rrm.mongorepository.ReportRepositoryImpl.reportRepository; nested exception is org.springframework.beans.factory.BeanCreationExceptio
    n: Error creating bean with name 'reportRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Mul
    tiple constructors with arguments found in class java.math.BigDecimal! Annotate one with @PreferedConstructor explicitly to select it to be used in persistence
    operations.
            at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.j
    ava:502)
            at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
            at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java
    :282)
            ... 54 more
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reportRepository': FactoryBean threw exception on object crea
    tion; nested exception is java.lang.IllegalArgumentException: Multiple constructors with arguments found in class java.math.BigDecimal! Annotate one with @Prefe
    redConstructor explicitly to select it to be used in persistence operations.
            at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
            at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1429)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:844)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
            at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.j
    ava:474)
            ... 56 more
    Caused by: java.lang.IllegalArgumentException: Multiple constructors with arguments found in class java.math.BigDecimal! Annotate one with @PreferedConstructor
    explicitly to select it to be used in persistence operations.
            at org.springframework.data.mapping.PreferredConstructorDiscoverer.<init>(PreferredConstructorDiscoverer.java:81)
            at org.springframework.data.mapping.BasicPersistentEntity.<init>(BasicPersistentEntity.java:49)
            at org.springframework.data.document.mongodb.mapping.BasicMongoPersistentEntity.<init>(BasicMongoPersistentEntity.java:47)
            at org.springframework.data.document.mongodb.mapping.MongoMappingContext.createPersistentEntity(MongoMappingContext.java:59)
            at org.springframework.data.document.mongodb.mapping.MongoMappingContext.createPersistentEntity(MongoMappingContext.java:33)
            at org.springframework.data.mapping.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:164)
            at org.springframework.data.mapping.AbstractMappingContext$1.doWith(AbstractMappingContext.java:201)
            at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:513)
            at org.springframework.data.mapping.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:176)
            at org.springframework.data.mapping.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:133)
            at org.springframework.data.mapping.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:114)
            at org.springframework.data.mapping.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:58)
            at org.springframework.data.document.mongodb.repository.MongoRepositoryFactoryBean$EntityInformationCreator.getEntityInformation(MongoRepositoryFactoryB
    ean.java:252)
            at org.springframework.data.document.mongodb.repository.MongoRepositoryFactoryBean$MongoRepositoryFactory.getEntityInformation(MongoRepositoryFactoryBea
    n.java:232)
            at org.springframework.data.document.mongodb.repository.MongoRepositoryFactoryBean$MongoRepositoryFactory.getTargetRepository(MongoRepositoryFactoryBean
    .java:154)
            at org.springframework.data.repository.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:133)
            at org.springframework.data.repository.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:107)
            at org.springframework.data.repository.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:36)
            at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
            ... 64 more

    Comment


    • #3
      Isn't anyone experiencing this issue with BigDecimal in a document?

      This exception always occurs when I have at least one BigDecimal field in one of my entities.
      I did a very dirty hack to avoid this problem, by annotating each BigDecimal field with @Value, then save the fields data manually by hooking into onBeforeSave and load the fields data manually by hooking into onAfterConvert.

      I still hope someone could enlighten me on this particular problem.

      Thanks in advance

      Edit: looks like the snapshot build fixed it, I'm going to check it thoroughly.
      Last edited by Fulvian; Jun 8th, 2011, 02:20 PM.

      Comment


      • #4
        The conversion issue you saw earlier was fixed as part of DATACMNS-42

        Are you actually getting data persisted? I'm getting the following when trying to persist an entity with a BigDecimal field:
        java.lang.IllegalArgumentException: can't serialize class java.math.BigDecimal

        I created a JIRA issue for this: DATADOC-171

        Comment

        Working...
        X