【发布时间】:2011-09-15 09:16:42
【问题描述】:
我想在使用最新 Grails 里程碑 (2.0.0.M1) 开发的应用程序中使用 JPA 域模型。 JPA 域类位于应用程序的src\java 目录中。
基于描述如何在 Grails 应用程序中使用现有 JPA 域模型的 this blog post,我创建了带有 JPA 注释类列表的 grails-app/conf/hibernate/hibernate.cfg.xml。
如果有人无聊到想自己运行应用程序,请联系here。当您运行应用程序时,启动时会出现以下错误
Error 2011-08-04 23:28:19,777 [Thread-8] ERROR context.GrailsContextLoader - Error executing bootstraps: Error creati
ng bean with name 'grailsDomainClassMappingContext': Instantiation of bean failed; nested exception is org.springframewo
rk.beans.BeanInstantiationException: Could not instantiate bean class [org.codehaus.groovy.grails.domain.GrailsDomainCla
ssMappingContext]: Constructor threw exception; nested exception is java.lang.NullPointerException
Line | Method
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 138 | run in java.util.concurrent.FutureTask
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run in ''
^ 662 | run . . in java.lang.Thread
Caused by BeanInstantiationException: Could not instantiate bean class [org.codehaus.groovy.grails.domain.GrailsDomainCl
assMappingContext]: Constructor threw exception; nested exception is java.lang.NullPointerException
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 138 | run in java.util.concurrent.FutureTask
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run in ''
^ 662 | run . . in java.lang.Thread
Caused by NullPointerException: null
->> 123 | addPersistentEntityInternal in org.grails.datastore.mapping.model.AbstractMappingContext
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 115 | addPersistentEntity in ''
| 127 | addPersistentEntityInternal in ''
| 115 | addPersistentEntity in ''
| 127 | addPersistentEntityInternal in ''
| 115 | addPersistentEntity in ''
| 303 | innerRun in java.util.concurrent.FutureTask$Sync
| 138 | run in java.util.concurrent.FutureTask
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run in ''
^ 662 | run . . in java.lang.Thread
奇怪的是,这个问题似乎只由与其他域类有关系的域类触发。如果您删除除SystemProperty 之外的所有域类(不引用其他域类),应用程序将正常启动。
【问题讨论】:
-
你为什么不创建你的域模型的 JAR 文件并在 Grails 应用程序中引用它。
-
该 ZIP 发行版中的 .war 文件是最新的吗?我在那里看不到那些依赖项。我也没有找到 hibernate.cfg.xml 文件。
-
ZIP 中没有 .war 文件,只有应用程序的源代码。您可以通过从应用程序根目录运行
grails war来生成战争,或者使用grails run-app运行它(不首先生成 .war)
标签: java grails jpa groovy grails-orm