Grails
  1. Grails
  2. GRAILS-8389

UniqueConstraint cast error when test with integration

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0-RC2
    • Fix Version/s: 2.0 final
    • Component/s: Persistence
    • Labels:
      None
    • Environment:
      Grails 2.0 RC2,JDK1.6,Lion

      Description

      in my plugin project,run test-app ,there is :
      Error executing script TestApp: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.ClassCastException: org.grails.datastore.gorm.validation.constraints.UniqueConstraint cannot be cast to org.codehaus.groovy.grails.orm.hibernate.validation.UniqueConstraint

      the stacktrace is:
      Caused by: java.lang.ClassCastException: org.grails.datastore.gorm.validation.constraints.UniqueConstraint cannot be cast to org.codehaus.groovy.grails.orm.hibernate.validation.UniqueConstraint
      at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1375)
      at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:717)
      at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1504)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1442)
      ... 79 more

        Activity

        Hide
        Ford Guo added a comment -

        I think i find the problem,cause there is a domain in my plugin project has such constraints:

        static constraints =

        { value min:-1//,unique:true //RC2 Bug? }
        Show
        Ford Guo added a comment - I think i find the problem,cause there is a domain in my plugin project has such constraints: static constraints = { value min:-1//,unique:true //RC2 Bug? }
        Hide
        Graeme Rocher added a comment -

        attach an example please

        Show
        Graeme Rocher added a comment - attach an example please
        Hide
        Chris Fraser added a comment -

        bug-report illustrating this problem, which happens when running "grails test-app" is attached.

        Show
        Chris Fraser added a comment - bug-report illustrating this problem, which happens when running "grails test-app" is attached.
        Hide
        Brian Saville added a comment -

        I am also running into the same problem - any known workarounds? I guess I can remove unique constraints for now.

        Show
        Brian Saville added a comment - I am also running into the same problem - any known workarounds? I guess I can remove unique constraints for now.
        Hide
        Leonid Vysochyn added a comment -

        Tried with the latest snapshot. Now got the following error when running test-app (separately integration and unit tests passed fine)

        | Error Error executing script TestApp: groovy.lang.MissingMethodException: No signature of method: org.grails.datastore.gorm.validation.constraints.UniqueConst
        raint$_withManualFlushMode_closure2.doCall() is applicable for argument types: ($Proxy37) values: [SessionImpl(<closed>)]
        Possible solutions: doCall(org.grails.datastore.mapping.core.Session), call(), call([Ljava.lang.Object;), call(java.lang.Object), call(org.grails.datastore.mapp
        ing.core.Session), findAll() (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
        groovy.lang.MissingMethodException: No signature of method: org.grails.datastore.gorm.validation.constraints.UniqueConstraint$_withManualFlushMode_closure2.doCa
        ll() is applicable for argument types: ($Proxy37) values: [SessionImpl(<closed>)]
        Possible solutions: doCall(org.grails.datastore.mapping.core.Session), call(), call([Ljava.lang.Object;), call(java.lang.Object), call(org.grails.datastore.mapp
        ing.core.Session), findAll()
                at $Proxy36.doInHibernate(Unknown Source)
                at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
                at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339)
                at com.db.lemg.pmtool.security.Person.withSession(Person.groovy)
                at com.db.lemg.pmtool.security.Person$withSession.call(Unknown Source)
                at com.db.lemg.pmtool.Release$withSession.call(Unknown Source)
                at org.grails.datastore.gorm.validation.constraints.UniqueConstraint.withManualFlushMode(UniqueConstraint.groovy:79)
                at org.grails.datastore.gorm.validation.constraints.UniqueConstraint$withManualFlushMode.callCurrent(Unknown Source)
                at org.grails.datastore.gorm.validation.constraints.UniqueConstraint.processValidate(UniqueConstraint.groovy:38)
        
        Show
        Leonid Vysochyn added a comment - Tried with the latest snapshot. Now got the following error when running test-app (separately integration and unit tests passed fine) | Error Error executing script TestApp: groovy.lang.MissingMethodException: No signature of method: org.grails.datastore.gorm.validation.constraints.UniqueConst raint$_withManualFlushMode_closure2.doCall() is applicable for argument types: ($Proxy37) values: [SessionImpl(<closed>)] Possible solutions: doCall(org.grails.datastore.mapping.core.Session), call(), call([Ljava.lang. Object ;), call(java.lang. Object ), call(org.grails.datastore.mapp ing.core.Session), findAll() (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.) groovy.lang.MissingMethodException: No signature of method: org.grails.datastore.gorm.validation.constraints.UniqueConstraint$_withManualFlushMode_closure2.doCa ll() is applicable for argument types: ($Proxy37) values: [SessionImpl(<closed>)] Possible solutions: doCall(org.grails.datastore.mapping.core.Session), call(), call([Ljava.lang. Object ;), call(java.lang. Object ), call(org.grails.datastore.mapp ing.core.Session), findAll() at $Proxy36.doInHibernate(Unknown Source) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339) at com.db.lemg.pmtool.security.Person.withSession(Person.groovy) at com.db.lemg.pmtool.security.Person$withSession.call(Unknown Source) at com.db.lemg.pmtool.Release$withSession.call(Unknown Source) at org.grails.datastore.gorm.validation.constraints.UniqueConstraint.withManualFlushMode(UniqueConstraint.groovy:79) at org.grails.datastore.gorm.validation.constraints.UniqueConstraint$withManualFlushMode.callCurrent(Unknown Source) at org.grails.datastore.gorm.validation.constraints.UniqueConstraint.processValidate(UniqueConstraint.groovy:38)
        Hide
        John Engelman added a comment - - edited

        I get the same error as Leonid with RC3. Interestingly, I do not get the error when running just integration tests, "grails test-app integration:", and all tests pass. When running the all test phases, "grails test-app", my integration tests fail when I try to save a domain object that has a unique constraint int it.

        Show
        John Engelman added a comment - - edited I get the same error as Leonid with RC3. Interestingly, I do not get the error when running just integration tests, "grails test-app integration:", and all tests pass. When running the all test phases, "grails test-app", my integration tests fail when I try to save a domain object that has a unique constraint int it.
        Hide
        Alex Weino added a comment -
        Show
        Alex Weino added a comment - Related: http://jira.grails.org/browse/GRAILS-8423
        Hide
        Chris Fraser added a comment - - edited

        I added a simple integration test to the bug-report that I uploaded to this JIRA issue the other day, and was able to recreate the problems that are being reported w/RC3. New bug-report is attached. See the User domain class for more details.

        Show
        Chris Fraser added a comment - - edited I added a simple integration test to the bug-report that I uploaded to this JIRA issue the other day, and was able to recreate the problems that are being reported w/RC3. New bug-report is attached. See the User domain class for more details.

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Ford Guo
          • Votes:
            4 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development