每当我尝试将我的应用程序部署到服务器时,我都会收到 JdbcSQLException,尽管在本地运行正常。我不知道这个错误是什么,似乎无法在谷歌上找到答案。
抛出错误的代码:
class ResultService {
def recentStoryRuns() {
StoryRun.list(sort: "batch.dateCreated", order: "desc")
}
}
完整的堆栈跟踪:
org.h2.jdbc.JdbcSQLException: Table "STORY_RUN" not found; SQL statement:
select this_.id as id3_1_, this_.version as version3_1_, this_.batch_id as batch3_3_1_, this_.batch_iteration as batch4_3_1_, this_.browser_string as browser5_3_1_, this_.easybresult_id as easybres6_3_1_, this_.failed_scenarios as failed7_3_1_, this_.last_parse_error as last8_3_1_, this_.passed_scenarios as passed9_3_1_, this_.result_parsed_story_status as result10_3_1_, this_.status as status3_1_, this_.story as story3_1_, this_.total_scenarios as total13_3_1_, this_.xml as xml3_1_, storyrunba1_.id as id2_0_, storyrunba1_.version as version2_0_, storyrunba1_.batch_id as batch3_2_0_, storyrunba1_.browsers_string as browsers4_2_0_, storyrunba1_.date_created as date5_2_0_, storyrunba1_.iterations as iterations2_0_, storyrunba1_.site_profile as site7_2_0_, storyrunba1_.stories_string as stories8_2_0_ from story_run this_ inner join story_run_batch storyrunba1_ on this_.batch_id=storyrunba1_.id order by storyrunba1_.date_created desc [42102-164]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:169)
at org.h2.message.DbException.get(DbException.java:146)
at org.h2.command.Parser.readTableOrView(Parser.java:4753)
at org.h2.command.Parser.readTableFilter(Parser.java:1080)
at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1686)
at org.h2.command.Parser.parseSelectSimple(Parser.java:1793)
at org.h2.command.Parser.parseSelectSub(Parser.java:1680)
at org.h2.command.Parser.parseSelectUnion(Parser.java:1523)
at org.h2.command.Parser.parseSelect(Parser.java:1511)
at org.h2.command.Parser.parsePrepared(Parser.java:405)
at org.h2.command.Parser.parse(Parser.java:279)
at org.h2.command.Parser.parse(Parser.java:251)
at org.h2.command.Parser.prepareCommand(Parser.java:217)
at org.h2.engine.Session.prepareLocal(Session.java:415)
at org.h2.engine.Session.prepareCommand(Session.java:364)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1121)
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:71)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:267)
at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:281)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:313)
at kindlingtests.ResultService.recentStoryRuns(ResultService.groovy:6)
at kindlingtests.HomeService.results(HomeService.groovy:19)
at kindlingtests.ModelFields$_closure1.doCall(ModelFields.groovy:13)
at kindlingtests.ModelFields.<init>(ModelFields.groovy:12)
at kindlingtests.HomeService.setControllerModelFields(HomeService.groovy:9)
at kindlingtests.HomeService.setControllerModelFields(HomeService.groovy:8)
at kindlingtests.HomeController.index(HomeController.groovy:14)
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:680)
[编辑]
根据要求,我的 DataSource.groovy:
dataSource {
pooled = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:devDb;MVCC=TRUE"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb;MVCC=TRUE"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:prodDb;MVCC=TRUE"
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
}
}