我创建了一个 Grails 应用程序,它正在顺利完成,我一直在与各种云提供商进行测试,例如 Cloud Foundry、Heroku、App Engine 等。最后我选择了 Jelastic,因为它是似乎完全支持使用本地插件,因为我只需要上传一个“战争”文件进行部署。
直到今天,我对此没有任何问题,一切都很好,但是我做了一些更改并为我的应用程序添加了一些关系,然后我使用 BootStrap 填充这些关系。这个 Bootstrap 以前可以工作,但现在已经停止,下面你可以看到我的 Bootstrap 示例:
def init = { servletContext ->
def adminRole = new SecRole(authority: 'ADMIN').save(flush: true)
def userRole = new SecRole(authority: 'USER').save(flush: true)
def Admin = new SecUser(username: 'admin', email:'admin@admin.com', enabled: true, password: 'password')
def SuperUser = new Areas(name:"SuperUser")
.addToUsers(Admin)
.save(flush:true)
SecUserSecRole.create Admin, adminRole, true
assert SecUser.count() == 1
assert SecRole.count() == 2
assert SecUserSecRole.count() == 1
}
当我使用此数据在本地运行应用程序时,BootStrap 工作正常,但是当我在 Jelastic 上运行它时,我收到以下错误消息:
SEVERE: Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; SQL
这只是错误发生位置的部分堆栈跟踪,但我不知道为什么会发生这种情况,有人可以帮忙吗?
谢谢
编辑.....
我也尝试过这个引导数据,显示相同的错误消息:S
def init = { servletContext ->
def adminRole = new SecRole(authority: 'ADMIN').save(flush: true)
def SuperAdmin = new Areas(name: 'Super Admin')
SuperAdmin.save(flush: true)
def area = Areas.findByName('SuperAdmin')
def SuperAdmin = new SecUser(username: 'admin', email:'test@test.com', area: area, enabled: true, password: 'admin')
SuperAdmin.save()
SecUserSecRole.create SuperAdmin, adminRole, true
assert SecUser.count() == 1
assert SecRole.count() == 2
assert SecUserSecRole.count() == 1
}
我收到的错误消息如下:
SEVERE: Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; SQL [select this_.id as id3_0_, this_.version as version3_0_, this_.account_expired as account3_3_0_, this_.account_locked as account4_3_0_, this_.area_id as area5_3_0_, this_.email as email3_0_, this_.enabled as enabled3_0_, this_."password" as password8_3_0_, this_.password_expired as password9_3_0_, this_.username as username3_0_ from sec_user this_ where this_.username=?]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
我已经剥离了 BootStrap 数据并且应用程序启动正常,任何人都可以对此有所了解,因为它在本地引导程序运行良好,而不是在云上?提前致谢