我创建了一个基于 Grails 的 Web 应用程序,如果我尝试在 BootStrap.groovy 文件中保存任何内容,它会在启动时崩溃。如果我注释掉文件save()
中的所有语句,BootStrap.groovy
则应用程序启动并且所有表都成功创建。
这是我的 BootStrap.groovy 文件:
class BootStrap
{
def init = { ServletContext context ->
// Register Custom Object Marshallers
WebApplicationContextUtils.getWebApplicationContext(context).getBean("customObjectMarshallers").register()
// Contact Type Tags
[
[ tag: "preferred" ],
[ tag: "default" ],
[ tag: "mobile" ],
[ tag: "cell" ],
[ tag: "work" ],
[ tag: "home" ],
].each {
def type = TypeTag.findByTag(it.tag)
if(!type) {
TypeTag tag = new TypeTag(tag: it.tag)
tag.validate()
tag.save()
def foo = "bar"
}
}
}
这就是日志中发生的情况:
Configuring Spring Security Core ...
... finished configuring Spring Security Core
| Error 2014-03-19 18:47:41,439 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: null
Message: null
Line | Method
->> 423 | initMetaDataColumnIndexes in oracle.jdbc.driver.AutoKeyInfo
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 396 | initMetaData in ''
| 77 | getMetaData . . . . . . . . . . in oracle.jdbc.driver.OracleReturnResultSet
| 39 | doCall in BootStrap$_closure1_closure3
| 27 | doCall . . . . . . . . . . . . . in BootStrap$_closure1
| 308 | evaluateEnvironmentSpecificBlock in grails.util.Environment
| 301 | executeForEnvironment . . . . . in ''
| 277 | executeForCurrentEnvironment in ''
| 262 | run . . . . . . . . . . . . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 744 | run in java.lang.Thread
Disconnected from the target VM, address: '127.0.0.1:60455', transport: 'socket'
在BootStrap.groovy
文件中,第 39 行是tag.save()
语句。如果我评论该行,那么应用程序就可以正常启动。该tag.validate()
行执行良好,此时对象中没有错误。
我正在运行 Java 1.7 update 45 和 Grails 2.3.7。我将 grails-hibernate 插件更新到 3.6.10.10。我在 lib 文件夹中也有 ojdbc7.jar 文件。Oracle 版本是 11gR2。
任何帮助深表感谢。