Announcement Announcement Module
Collapse
No announcement yet.
Adding a new domain class causing compile error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding a new domain class causing compile error

    I have created a new domain object in an existing Grails 1.3.7 project.

    Code:
    package com.xfitlog
    
    class Implement {
        String name
        String description
        String abbreviation
    
        static belongsTo = [exercise : Exercise]
    
        static constraints = {
            name( nullable: false, unique: true )
            description( nullable: false, maxSize: 2000 )
            abbreviation( nullable: true )
        }
    
        String toString() {
            "${name}"   
        }
    }
    I then link the new 'Implement' class to the existing 'Exercise' class.

    Code:
    class Exercise{
    
        String          name
        String          description
        boolean         isApproved
        Implement       implement
    
        static constraints = {
            name            ( nullable: false )
            description     ( nullable: false, maxSize: 5000 )
            isApproved      ( nullable: true )
            implement       ( nullable: true )
        }
    
        String toString() {
            "${name}"
        }   
    }
    When I run grails run-app through the windows command prompt I get the following errors:

    Running Grails application..
    loading security config ...
    2012-03-13 09:15:26,040 [main] ERROR context.GrailsContextLoader - Error executing bootstraps: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.facto
    ry.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: An association from the table exercise refers to an unmapped class: com.xfitlog.Implement
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creatin
    g bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: An association from the table exercise refers to an unmapped class: com.xfitlog.Implement
    at org.grails.tomcat.TomcatServer.start(TomcatServer. groovy:212)
    at grails.web.container.EmbeddableServer$start$0.call (Unknown Source)
    at _GrailsRun_groovy$_run_closure5_closure12.doCall(_ GrailsRun_groovy:158)
    at _GrailsRun_groovy$_run_closure5_closure12.doCall(_ GrailsRun_groovy)
    at _GrailsSettings_groovy$_run_closure10.doCall(_Grai lsSettings_groovy:280)
    at _GrailsSettings_groovy$_run_closure10.call(_Grails Settings_groovy)
    at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_ groovy:149)
    at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_gr oovy)
    at _GrailsRun_groovy.runInline(_GrailsRun_groovy:116)
    at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groo vy)
    at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_ groovy:59)
    at _GrailsRun_groovy$_run_closure8_closure14.doCall(_ GrailsRun_groovy:263)
    at _GrailsRun_groovy$_run_closure8_closure14.doCall(_ GrailsRun_groovy)
    at _GrailsPackage_groovy$_run_closure8.doCall(_Grails Package_groovy:299)
    at _GrailsPackage_groovy$_run_closure8.call(_GrailsPa ckage_groovy)
    at _GrailsRun_groovy$_run_closure8.doCall(_GrailsRun_ groovy:245)
    at RunApp$_run_closure1.doCall(RunApp.groovy:35)
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:38 1)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:41 5)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
    at gant.Gant.withBuildListeners(Gant.groovy:427)
    at gant.Gant.this$2$withBuildListeners(Gant.groovy)
    at gant.Gant$this$2$withBuildListeners.callCurrent(Un known Source)
    at gant.Gant.dispatch(Gant.groovy:415)
    at gant.Gant.this$2$dispatch(Gant.groovy)
    at gant.Gant.invokeMethod(Gant.groovy)
    at gant.Gant.executeTargets(Gant.groovy:590)
    at gant.Gant.executeTargets(Gant.groovy:589)
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: An association from the
    table exercise refers to an unmapped class: com.xfitlog.Implement
    ... 28 more
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: An association from the table exercise refers to an unmapped class: com.xfitlog.Implement
    ... 28 more
    Caused by: org.hibernate.MappingException: An association from the table exercise refers to an unmapped class: com.xfitlog.Implement
    ... 28 more
    Application context shutting down...
    Application context shutdown.
    I think this problem is in the project itself. Anytime I add a new domain class I get the 'unmapped class' error, even though grails will create a controller and views for the new domain class.

    Thank you for your help
Working...
X