0
votes

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

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}"   
    }
}

This class links to the 'Implement' class.

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:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 's essionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.h ibernate.MappingException: An association from the table exercise refers to an unmapped class: com.xfitlog.Implement ... 28 more Caused by: org.springframework.beans.factory.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 ... 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...

I have tried creating a new project and adding these same domain classes and everything works fine. I don't know what has changed in my original project but something is messed up.

Thank you for your help.

1
have you tried grails clean?zoran119
Make sure the domain classes are in grails-app/domain and that the class packages match the directories.ataylor
I have run grails clean several times. The domain classes are in the same package and directory as all of the older classes that are functioning correctly.user1172234

1 Answers

0
votes

Make sure you're not mixing hibernate hbm.xml classes with domain objects. I got a similar error and this turned out to be the issue.

my current app mixes old style groovy pojo ( basically a java pojo written in groovy) using hiberate mapping files in a library and domain classes in the main project.

Also make sure that all of your domain classes have the correct import and package statements.