2
votes

I am new on Grails (2.4.1). I am trying to use joda time (1.5). When I put the script below to my Config.groovy an error occurrs.

grails.gorm.default.mapping = {
    "user-type" type: org.jadira.usertype.dateandtime.joda.PersistentDateTime, class: org.joda.time.DateTime
    "user-type" type: org.jadira.usertype.dateandtime.joda.PersistentLocalDate, class: org.joda.time.LocalDate
    // … define as many other user type mappings as you need
}

error: Error | 2014-07-12 23:45:31,632 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener - Error initializing the application: 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.NoClassDefFoundError: org/hibernate/engine/SessionImplementor Message: 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.NoClassDefFoundError: org/hibernate/engine/SessionImplementor

etc.

1
The error is raised in line 4...Nir Alfasi
If you change your project to use Hibernate 3 instead of 4 does it work?Joshua Moore
Hi Joshua, thanks for your response! I changed the hibernate version, but the error yet occurrs. Please, see it: // plugins needed at runtime but not for compilation runtime ":hibernate:3.6.10.16" // ":hibernate4:4.3.5.4" error: etc... etc... (the same of the last post) and: Caused by HibernateException: could not instantiate RegionFactory [org.hibernate.cache.ehcache.EhCacheRegionFactory]... etc.... Thanks a lot!Pedro Gentil

1 Answers

4
votes

I fixed the same error by upgrading the Jadira Usertype library dependency that the plugin was using.

The Joda Time plugin recommends "org.jadira.usertype:usertype.jodatime:1.9", which only works for Hibernate 3. Try switching to "org.jadira.usertype:usertype.core:3.2.0.GA" when using Hibernate 4.