我正在将应用程序从Grails 1.3.9升级到Grails 2.2.1。当我发出run-app命令时,我得到一个以这个错误开头的长堆栈跟踪,然后或多或少地重复它大约400行:
2013-03-07 13:32:11.364 ERROR [ StackTrace] Full Stack Trace:
org.springframework.beans.factory.BeanCreationException: 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 org.hibernate.MappingException: property [sponsoringManager] not found on entity [com.mycompany.myapp.ManagerDelegate]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.doCreateBean(ReloadAwareAutowireCapableBeanFactory.java:118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:713)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:457)
at org.codehaus.groovy.grails.commons.spring.DefaultRuntimeSpringConfiguration.getApplicationContext(DefaultRuntimeSpringConfiguration.java:153)
at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:170)
at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:127)
at org.codehaus.groovy.grails.web.context.GrailsConfigUtils.configureWebApplicationContext(GrailsConfigUtils.java:121)
at org.codehaus.groovy.grails.web.context.GrailsContextLoader.initWebApplicationContext(GrailsContextLoader.java:107)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
我认为相关部分是这样的:
org.hibernate.MappingException: property [sponsoringManager] not found on entity [com.mycompany.myapp.ManagerDelegate]
这是ManagerDelegate域类的代码,它是多对多的连接类:
package com.mycompany.myapp
class ManagerDelegate extends Base implements Serializable {
static belongsTo = [sponsoringManager:User, delegate:User]
boolean equals(other) {
if (!(other instanceof ManagerDelegate)) {
return false
}
other.sponsoringManager.id == sponsoringManager.id && other.delegate.id == delegate.id
}
static mapping = {
id composite: [
'sponsoringManager',
'delegate'
]
version false
}
}
如您所见,ManagerDelegate确实包含一个sponsoringManager属性,该属性在belongsTo语句中声明。这在Grails 1.3.9中完美运行。
这是User类:
class User {
static hasMany = [sponsoringManagers: ManagerDelegate, delegates: ManagerDelegate]
static mappedBy = [sponsoringManagers: "delegate", delegates: "sponsoringManager"]
static mapping = {
id generator: 'uuid'
sponsoringManagers cascade: 'all-delete-orphan'
delegates cascade: 'all-delete-orphan'
}
...
}
当我尝试从浏览器访问应用程序时,不会显示任何内容,也不会生成日志输出。