Grails

DuplicateMappingException when using groovy Domain classes mapped by HIbernate *.hbm.xml files

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 0.2
  • Fix Version/s: 0.2
  • Component/s: Configuration, Persistence
  • Labels:
    None
  • Environment:
    HSQL, PostgreSQL databases tested.
  • Testcase included:
    yes

Description

We have groovy Domain classes, which are to be mapped, not by GORM, but directly with Hibernate hbm.xml files.

When satrting the application, grails tries to map the domain classes twice. When it does the second time, a DuplicateMappingException occurs.

Excerpt from the log:

{{
[groovy] configuring from url: file:/C:/dev/dup/tmp/war/WEB-INF/classes/hibernate.cfg.xml
[groovy] Reading mappings from resource: Author.hbm.xml
[groovy] Mapping class: Author -> author
[groovy] Reading mappings from resource: Book.hbm.xml
[groovy] Mapping class: Book -> book
[groovy] Configured SessionFactory: null
[groovy] Building new Hibernate SessionFactory
[groovy] [GrailsDomainBinder] Mapping Grails domain class: Author -> AUTHOR
[groovy] [GrailsDomainBinder] bound property [org.codehaus.groovy.grails.commons.DefaultGrailsDomainClassProperty@191f022[name=id,type=class java.lang.Long,persistent=true,optional=false,association=false,bidirectional=false,association-type=<null>]] to column name [ID]
[groovy] [GrailsDomainBinder] Set cascading strategy on property [id] to [null]
[groovy] [GrailsDomainBinder] bound property [org.codehaus.groovy.grails.commons.DefaultGrailsDomainClassProperty@2c5444[name=version,type=class java.lang.Long,persistent=true,optional=false,association=false,bidirectional=false,association-type=<null>]] to column name [VERSION]
[groovy] [GrailsDomainBinder] Set cascading strategy on property [version] to [null]
[groovy] [GrailsDomainBinder] Binding persistent property [name]
[groovy] [GrailsDomainBinder] bound property [org.codehaus.groovy.grails.commons.DefaultGrailsDomainClassProperty@c74fe[name=name,type=class java.lang.String,persistent=true,optional=false,association=false,bidirectional=false,association-type=<null>]] to column name [NAME]
[groovy] [GrailsDomainBinder] Set cascading strategy on property [name] to [null]
[groovy] Destroying singletons in factory {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [customEditors,exceptionHandler,multipartResolver,messageSource,localeChangeInterceptor,localeResolver,dataSource,sessionFactory,transactionManager,AuthorDomainClass,AuthorPersistentClass,AuthorValidator,BookDomainClass,BookPersistentClass,BookValidator,simpleGrailsController,jspViewResolver,handlerMappingTargetSource,openSessionInViewInterceptor,handlerMapping,AuthorControllerClass,AuthorControllerTargetSource,AuthorControllerProxy,AuthorController,BookControllerClass,BookControllerTargetSource,BookControllerProxy,BookController,ValidationTagLibClass,ValidationTagLibTargetSource,ValidationTagLibProxy,ValidationTagLib,JavascriptTagLibClass,JavascriptTagLibTargetSource,JavascriptTagLibProxy,JavascriptTagLib,FormTagLibClass,FormTagLibTargetSource,FormTagLibProxy,FormTagLib,RenderTagLibClass,RenderTagLibTargetSource,RenderTagLibProxy,RenderTagLib,UITagLibClass,UITagLibTargetSource,UITagLibProxy,UITagLib,ApplicationTagLibClass,ApplicationTagLibTargetSource,ApplicationTagLibProxy,ApplicationTagLib,AuthorScaffoldDomain,AuthorControllerScaffolder,BookScaffoldDomain,BookControllerScaffolder]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [grailsApplication,grailsResourceHolder,characterEncodingFilter]; root of BeanFactory hierarchy}
[groovy] Context initialization failed [groovy] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in resource loaded through InputStream: Initialization of bean failed; nested exception is org.hibernate.DuplicateMappingException: Duplicate class/entity mapping Author
[groovy] org.hibernate.DuplicateMappingException: Duplicate class/entity mapping Author
[groovy] at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
[groovy] at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.bindRoot(GrailsDomainBinder.java:327)
[groovy] at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.bindClass(GrailsDomainBinder.java:278)
[groovy] at org.codehaus.groovy.grails.orm.hibernate.cfg.DefaultGrailsDomainConfiguration.secondPassCompile(DefaultGrailsDomainConfiguration.java:118)
[groovy] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1168)
[groovy] at org.codehaus.groovy.grails.orm.hibernate.cfg.DefaultGrailsDomainConfiguration.buildSessionFactory(DefaultGrailsDomainConfiguration.java:88)
[groovy] at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:800)
[groovy] at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:726)
[groovy] at org.codehaus.groovy.grails.orm.hibernate.ConfigurableLocalSessionFactoryBean.afterPropertiesSet(ConfigurableLocalSessionFactoryBean.java:92)
[groovy] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1059)
[groovy] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:363)
[groovy] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
[groovy] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
[groovy] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:269)
[groovy] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:320)
[groovy] at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
[groovy] at org.springmodules.beans.factory.drivers.xml.XmlWebApplicationContextDriver.getWebApplicationContext(XmlWebApplicationContextDriver.java:54)
[groovy] at org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.createWebApplicationContext(GrailsDispatcherServlet.java:78)
[groovy] at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:250)
[groovy] at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:219)
[groovy] at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:112)
[groovy] at javax.servlet.GenericServlet.init(GenericServlet.java:168)
[groovy] at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:383)
[groovy] at org.mortbay.jetty.servlet.ServletHolder.start(ServletHolder.java:243)
[groovy] at org.mortbay.jetty.servlet.ServletHandler.initializeServlets(ServletHandler.java:446)
[groovy] at org.mortbay.jetty.servlet.WebApplicationHandler.initializeServlets(WebApplicationHandler.java:321)
[groovy] at org.mortbay.jetty.servlet.WebApplicationContext.doStart(WebApplicationContext.java:511)
[groovy] at org.mortbay.util.Container.start(Container.java:72)
[groovy] at org.mortbay.http.HttpServer.doStart(HttpServer.java:753)
[groovy] at org.mortbay.util.Container.start(Container.java:72)
[groovy] at gjdk.org.mortbay.jetty.Server_GroovyReflector.invoke(Unknown Source)
[groovy] at groovy.lang.MetaMethod.invoke(MetaMethod.java:111)
[groovy] at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:652)
[groovy] at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:343)
[groovy] at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:144)
[groovy] at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:104)
[groovy] at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod(ScriptBytecodeAdapter.java:85)
[groovy] at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeNoArgumentsMethod(ScriptBytecodeAdapter.java:175)
[groovy] at Script1.run(Script1.groovy:11)
[groovy] at org.codehaus.groovy.ant.Groovy.execGroovy(Groovy.java:455)
[groovy] at org.codehaus.groovy.ant.Groovy.execute(Groovy.java:349)
[groovy] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[groovy] at org.apache.tools.ant.Task.perform(Task.java:364)
[groovy] at org.apache.tools.ant.Target.execute(Target.java:341)
[groovy] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[groovy] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[groovy] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37)
[groovy] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[groovy] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382)
[groovy] at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:107)
[groovy] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[groovy] at org.apache.tools.ant.Task.perform(Task.java:364)
[groovy] at org.apache.tools.ant.Target.execute(Target.java:341)
[groovy] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[groovy] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[groovy] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[groovy] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[groovy] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[groovy] at org.apache.tools.ant.Main.runBuild(Main.java:668)
[groovy] at org.apache.tools.ant.Main.startAnt(Main.java:187)
[groovy] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
[groovy] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
}}

Activity

Hide
Luis Muniz added a comment -

The test case can be replicated by
-creating the grails app dup,
-copying the into the newly created app
-domain classes
-controllers
-hibernate config
-grails run-app

Show
Luis Muniz added a comment - The test case can be replicated by -creating the grails app dup, -copying the into the newly created app -domain classes -controllers -hibernate config -grails run-app
Hide
Per Olesen added a comment -

I am currently getting this very exception, while trying to add some hibernate mapping through hbm.xml files to a grails domain class.
Should I re-open this case.
I am using grails 1.1.1 so I think it is strange, if this old bug should be my problem, though it sounds like it is.

Show
Per Olesen added a comment - I am currently getting this very exception, while trying to add some hibernate mapping through hbm.xml files to a grails domain class. Should I re-open this case. I am using grails 1.1.1 so I think it is strange, if this old bug should be my problem, though it sounds like it is.
Hide
Frederico Costa Galvão added a comment -

I'm upgrading a 1.1 big app onto 1.3.6, and have fallen in a very similar stacktrace as this.

Error executing script TestApp: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': 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 org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': 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 org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:391)
	at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
	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(Unknown 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.BeanCreationException: Error creating bean with name 'messageSource': 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 org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	at _GrailsBootstrap_groovy$_run_closure2_closure14.doCall(_GrailsBootstrap_groovy:102)
	at _GrailsBootstrap_groovy$_run_closure2_closure14.doCall(_GrailsBootstrap_groovy)
	at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
	at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
	at _GrailsBootstrap_groovy$_run_closure2.doCall(_GrailsBootstrap_groovy:94)
	at _GrailsBootstrap_groovy$_run_closure6.doCall(_GrailsBootstrap_groovy:152)
	at _GrailsTest_groovy$_run_closure9.doCall(_GrailsTest_groovy:314)
	at _GrailsTest_groovy$_run_closure9.doCall(_GrailsTest_groovy)
	at _GrailsTest_groovy$_run_closure1_closure21.doCall(_GrailsTest_groovy:184)
	at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:174)
	at TestApp$_run_closure1.doCall(TestApp.groovy:82)
	at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
	... 10 more
Caused by: 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 org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	... 22 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	... 22 more
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	... 22 more
--- Nested Exception ---
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': 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 org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	at _GrailsBootstrap_groovy$_run_closure2_closure14.doCall(_GrailsBootstrap_groovy:102)
	at _GrailsBootstrap_groovy$_run_closure2_closure14.doCall(_GrailsBootstrap_groovy)
	at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
	at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
	at _GrailsBootstrap_groovy$_run_closure2.doCall(_GrailsBootstrap_groovy:94)
	at _GrailsBootstrap_groovy$_run_closure6.doCall(_GrailsBootstrap_groovy:152)
	at _GrailsTest_groovy$_run_closure9.doCall(_GrailsTest_groovy:314)
	at _GrailsTest_groovy$_run_closure9.doCall(_GrailsTest_groovy)
	at _GrailsTest_groovy$_run_closure1_closure21.doCall(_GrailsTest_groovy:184)
	at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:174)
	at TestApp$_run_closure1.doCall(TestApp.groovy:82)
	at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
	at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
	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(Unknown 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.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 org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	... 22 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	... 22 more
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	... 22 more
Error executing script TestApp: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': 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 org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario

I have br.com.fibonacci.dominio.compartilhado.Beneficiario.groovy in 'grails-app/domain' , and Beneficiario.hbm.xml in 'grails-app/conf/hibernate'.

In hibernate.cfg.xml I have

<mapping resource="Beneficiario.hbm.xml"/>

and the hbm file is alright. The app was being mapped correctly in 1.1, but cannot be ran or tested now.

:Ubuntu 10.04-generic kernel
sun-java6-jdk 6u22, grails 1.3.6/ groovy 1.7.5

Show
Frederico Costa Galvão added a comment - I'm upgrading a 1.1 big app onto 1.3.6, and have fallen in a very similar stacktrace as this.
Error executing script TestApp: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': 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 org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': 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 org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:391)
	at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
	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(Unknown 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.BeanCreationException: Error creating bean with name 'messageSource': 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 org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	at _GrailsBootstrap_groovy$_run_closure2_closure14.doCall(_GrailsBootstrap_groovy:102)
	at _GrailsBootstrap_groovy$_run_closure2_closure14.doCall(_GrailsBootstrap_groovy)
	at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
	at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
	at _GrailsBootstrap_groovy$_run_closure2.doCall(_GrailsBootstrap_groovy:94)
	at _GrailsBootstrap_groovy$_run_closure6.doCall(_GrailsBootstrap_groovy:152)
	at _GrailsTest_groovy$_run_closure9.doCall(_GrailsTest_groovy:314)
	at _GrailsTest_groovy$_run_closure9.doCall(_GrailsTest_groovy)
	at _GrailsTest_groovy$_run_closure1_closure21.doCall(_GrailsTest_groovy:184)
	at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:174)
	at TestApp$_run_closure1.doCall(TestApp.groovy:82)
	at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
	... 10 more
Caused by: 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 org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	... 22 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	... 22 more
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	... 22 more
--- Nested Exception ---
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': 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 org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	at _GrailsBootstrap_groovy$_run_closure2_closure14.doCall(_GrailsBootstrap_groovy:102)
	at _GrailsBootstrap_groovy$_run_closure2_closure14.doCall(_GrailsBootstrap_groovy)
	at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
	at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
	at _GrailsBootstrap_groovy$_run_closure2.doCall(_GrailsBootstrap_groovy:94)
	at _GrailsBootstrap_groovy$_run_closure6.doCall(_GrailsBootstrap_groovy:152)
	at _GrailsTest_groovy$_run_closure9.doCall(_GrailsTest_groovy:314)
	at _GrailsTest_groovy$_run_closure9.doCall(_GrailsTest_groovy)
	at _GrailsTest_groovy$_run_closure1_closure21.doCall(_GrailsTest_groovy:184)
	at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:174)
	at TestApp$_run_closure1.doCall(TestApp.groovy:82)
	at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
	at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
	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(Unknown 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.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 org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	... 22 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	... 22 more
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
	... 22 more
Error executing script TestApp: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': 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 org.hibernate.DuplicateMappingException: Duplicate class/entity mapping br.com.fibonacci.dominio.compartilhado.Beneficiario
I have br.com.fibonacci.dominio.compartilhado.Beneficiario.groovy in 'grails-app/domain' , and Beneficiario.hbm.xml in 'grails-app/conf/hibernate'. In hibernate.cfg.xml I have
<mapping resource="Beneficiario.hbm.xml"/>
and the hbm file is alright. The app was being mapped correctly in 1.1, but cannot be ran or tested now. :Ubuntu 10.04-generic kernel sun-java6-jdk 6u22, grails 1.3.6/ groovy 1.7.5
Hide
Frederico Costa Galvão added a comment -

I have found that the grails/hibernate documentation does note quote that the path to the hbm files into conf/hibernate folder must follow the package structure of the domain class it maps.

If I move Beneficiario.hbm.xml from ${appName}/grails-app/conf/hibernate/
to ${appName}/grails-app/conf/hibernate/br/com/fibonacci/dominio/compartilhado/
as is the domain class packaged, it works properly. This info should be in section
"15.1 Using Hibernate XML Mapping Files", in my opinion.

Show
Frederico Costa Galvão added a comment - I have found that the grails/hibernate documentation does note quote that the path to the hbm files into conf/hibernate folder must follow the package structure of the domain class it maps. If I move Beneficiario.hbm.xml from ${appName}/grails-app/conf/hibernate/ to ${appName}/grails-app/conf/hibernate/br/com/fibonacci/dominio/compartilhado/ as is the domain class packaged, it works properly. This info should be in section "15.1 Using Hibernate XML Mapping Files", in my opinion.
Hide
Graeme Rocher added a comment -

Bulk closing bunch of resolved issues

Show
Graeme Rocher added a comment - Bulk closing bunch of resolved issues

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: