2010-02-19 96 views
0

我的Grails應用程序出現令人沮喪的問題。我能夠在沒有任何問題的情況下使用run-app和run-war運行應用程序,但是當我嘗試部署到容器時,我遇到了一個我不知道如何解釋的異常。我試過在Glassfish,Tomcat和Jetty上部署,並且在所有三個容器中都有相同的問題。Grails 1.2.0部署問題:org.hibernate.MappingException

任何幫助理解什麼可能會導致這種情況,以及我應該尋找什麼潛在的問題,將不勝感激。

堆棧日誌如下:

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.MappingException: Type [null] is not a basic type or a domain class and cannot be mapped. Either specify a type within the [mapping] block or use a basic type (String, Integer etc.) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) 
     at org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.doCreateBean(ReloadAwareAutowireCapableBeanFactory.java:124) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) 
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) 
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) 
     at org.springframework.context.support.AbstractApplicationContext.initMessageSource(AbstractApplicationContext.java:714) 
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:404) 
     at org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext.refresh(GrailsWebApplicationContext.java:153) 
     at org.codehaus.groovy.grails.commons.spring.DefaultRuntimeSpringConfiguration.getApplicationContext(DefaultRuntimeSpringConfiguration.java:154) 
     at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:170) 
     at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:131) 
     at org.codehaus.groovy.grails.web.context.GrailsConfigUtils.configureWebApplicationContext(GrailsConfigUtils.java:102) 
     at org.codehaus.groovy.grails.web.context.GrailsContextLoader.createWebApplicationContext(GrailsContextLoader.java:68) 
     at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192) 
     at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) 
     at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548) 
     at org.mortbay.jetty.servlet.Context.startContext(Context.java:136) 
     at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250) 
     at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) 
     at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467) 
     at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 
     at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) 
     at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156) 
     at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 
     at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) 
     at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 
     at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) 
     at org.mortbay.jetty.Server.doStart(Server.java:224) 
     at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 
     at org.mortbay.xml.XmlConfiguration.main(XmlConfiguration.java:985) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
     at java.lang.reflect.Method.invoke(Unknown Source) 
     at org.mortbay.start.Main.invokeMain(Main.java:194) 
     at org.mortbay.start.Main.start(Main.java:534) 
     at org.mortbay.start.Main.start(Main.java:441) 
     at org.mortbay.start.Main.main(Main.java:119) 
2010-02-19 09:30:18.316:WARN::Nested in 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.MappingException: Type [null] is not a basic type or a domain class and cannot be mapped. Either specify a type within the [mapping] block or use a basic type (String, Integer etc.): 
org.hibernate.MappingException: Type [null] is not a basic type or a domain class and cannot be mapped. Either specify a type within the [mapping] block or use a basic type (String, Integer etc.) 
     at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.bindCollectionWithJoinTable(GrailsDomainBinder.java:568) 
     at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.bindCollectionSecondPass(GrailsDomainBinder.java:502) 
     at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.access$100(GrailsDomainBinder.java:66) 
     at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder$GrailsCollectionSecondPass.doSecondPass(GrailsDomainBinder.java:207) 
     at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1163) 
     at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:329) 
     at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration.secondPassCompile(GrailsAnnotationConfiguration.java:143) 
     at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1148) 
     at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:717) 
     at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512) 
     at org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.doCreateBean(ReloadAwareAutowireCapableBeanFactory.java:124) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) 
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) 
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) 
     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322) 
     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1305) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511) 
     at org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.doCreateBean(ReloadAwareAutowireCapableBeanFactory.java:124) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) 
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) 
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) 
     at org.codehaus.groovy.grails.orm.support.TransactionManagerPostProcessor.postProcessAfterInstantiation(TransactionManagerPostProcessor.java:81) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1017) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511) 
     at org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.doCreateBean(ReloadAwareAutowireCapableBeanFactory.java:124) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) 
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) 
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) 
     at org.springframework.context.support.AbstractApplicationContext.initMessageSource(AbstractApplicationContext.java:714) 
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:404) 
     at org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext.refresh(GrailsWebApplicationContext.java:153) 
     at org.codehaus.groovy.grails.commons.spring.DefaultRuntimeSpringConfiguration.getApplicationContext(DefaultRuntimeSpringConfiguration.java:154) 
     at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:170) 
     at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:131) 
     at org.codehaus.groovy.grails.web.context.GrailsConfigUtils.configureWebApplicationContext(GrailsConfigUtils.java:102) 
     at org.codehaus.groovy.grails.web.context.GrailsContextLoader.createWebApplicationContext(GrailsContextLoader.java:68) 
     at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192) 
     at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) 
     at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548) 
     at org.mortbay.jetty.servlet.Context.startContext(Context.java:136) 
     at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250) 
     at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) 
     at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467) 
     at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 
     at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) 
     at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156) 
     at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 
     at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) 
     at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 
     at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) 
     at org.mortbay.jetty.Server.doStart(Server.java:224) 
     at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 
     at org.mortbay.xml.XmlConfiguration.main(XmlConfiguration.java:985) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
     at java.lang.reflect.Method.invoke(Unknown Source) 
     at org.mortbay.start.Main.invokeMain(Main.java:194) 
     at org.mortbay.start.Main.start(Main.java:534) 
     at org.mortbay.start.Main.start(Main.java:441) 
     at org.mortbay.start.Main.main(Main.java:119) 

回答

0

發現了它。靜態映射塊導致了錯誤。

static mapping { contents type 'text' } 
1

我有一個類似的錯誤。在產生戰爭之前,我清理了我的應用程序(grails clean),問題消失了。也許有對舊域類的引用,我不知道。

1

我下雨到同樣的問題,對我來說,它發生了,一旦我切換到Grails 1.2。解決方案並不是那麼明顯,堆棧跟蹤當然沒有說明問題。

您不能在相同的文件中聲明域對象,例如hasMany。每個域對象應該在一個單獨的文件中聲明。

http://www.manning-sandbox.com/message.jspa?messageID=80964

0

這個問題似乎在一組完全不同的條件下飼養。

它發生在我將應用程序從grails 1.1升級到grails 1.2的情況下:在這種情況下,觸發器是與使用枚舉的域類相同的文件中的枚舉定義:這不會導致1.1下的任何問題, 1.2我得到了臭名昭著:

Error creating bean with name 'sessionFactory': Invocation of init method failed; 
nested exception is org.hibernate.MappingException: Type [null] is not a basic type or a domain class and cannot be mapped. 
Either specify a type within the [mapping] block or use a basic type (String, Integer etc.) 

把枚舉在一個單獨的文件解決了這個問題。

如此看來,Grails的1.2是一個比較挑剔發生的事情在一個領域類的源文件,對於1.1 ....