0

I'm upgrading a 2.3 app to 2.4.4 and I have several domains that use List fields similar to the following and I'm receiving an error as described here.

class Game {
  List score

  static hasMany = [ score: Integer ]
}

I'm assuming use of the above is the actual cause of the problem but I can't be sure because the error message doesn't point to a domain.

Is this type of list definition not good grails practice?

I get the error:

2014-10-31 16:26:32 ERROR [context.GrailsContextLoaderListener] Error initializing the pplication: Error creating bean with name 'transactionManagerPostProcessor':
.... 
Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: java.util.List

UPDATE

I found the domain and the problem associated with the error. Here's the problem domain and associated List. If I remove the List, the problem is corrected.

class Team {
  List teamTourney

  static hasMany = [ teamTourney: TeamTourney ]
}
Community
  • 1
  • 1
SeattleStephens
  • 587
  • 8
  • 20
  • "I'm assuming use of the above is the actual cause of the problem but I can't be sure because the error message doesn't point to a domain." - Why is it that you think the problem is related to a domain if the error message doesn't point to that? – Jeff Scott Brown Dec 01 '14 at 22:17

3 Answers3

2

For anyone that might receive this error in the future you can add

log4j = {
    debug  'org.codehaus.groovy.grails.orm.hibernate.cfg'
}

to the config and it will tell you what class and property is causing the problem.

dspies
  • 1,545
  • 14
  • 19
1

Is this type of list definition not good grails practice?

The code that you show there should be fine. See the project at https://github.com/jeffbrown/integerlist.

Jeff Scott Brown
  • 26,804
  • 2
  • 30
  • 47
  • The error states `Association references unmapped class: java.util.List` but doesn't specify the domain (of the 23 in this project) causing the problem. Will report back when I find the issue. Thanks. – SeattleStephens Dec 02 '14 at 00:44
  • I would expect that message if you had a persistent untyped collection defined but that isn't he case in the code you have shown. The `hasMany` indicates what type of objects are stored in the `score` collection. If you comment out the `hasMany`, that error would arise. I would look for a collection that isn't represented in your `hasMany` somewhere. – Jeff Scott Brown Dec 02 '14 at 02:20
  • I found the domain with the problem and updated the question above. I have a one-to-many relationship between domains and I defined it as a List. If I remove the List, it corrects the problem. – SeattleStephens Dec 02 '14 at 17:23
  • There has to be some other factor in your app. The `Team` class you show there is completely standard stuff and people do that all of the time. If you can isolate the problem into an app that you can push to github or share somewhere else, I would be happy to take a look at it. – Jeff Scott Brown Dec 02 '14 at 17:35
  • Thanks. I've just made a simple author/book example and specifying `List books` in the `Author` domain does not duplicate the problem. As you suggest, there must be something more going on. – SeattleStephens Dec 02 '14 at 21:22
0

The problem was a List referencing an undefined field. Among the domains in my project was a type-o in the field name associated with a List. It would be nice if the error message pointed at the location of the error, a point also in this post.

Thanks, Scott.

Community
  • 1
  • 1
SeattleStephens
  • 587
  • 8
  • 20