0

我正在将应用程序从 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 确实包含在 belongsTo 语句中声明的赞助管理器属性。这在 Grails 1.3.9 中完美运行。

这是用户类:

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'
    }

    ...

}

当我尝试从浏览器访问应用程序时,没有显示任何内容,也没有生成日志输出。

4

0 回答 0