I am developing an application using Play! 1.2.5 and I have some data in conf\initial-data.yaml. I'm using H2 in-memory tables. This works fine when I run the application with play run. However when I package it into ROOT.war file and deploy it on tomcat, I get this error:
21:43:09,424 INFO ~ Connected to jdbc:h2:mem:play;MODE=MYSQL
21:43:11,006 INFO ~ Application 'myapp' is now started !
21:43:11,296 WARN ~ SQL Error: 42102, SQLState: 42S02
21:43:11,298 ERROR ~ Table "USER" not found; SQL statement:
select count(*) as col_0_0_ from User user0_ limit ? [42102-166]
21:43:11,320 ERROR ~
@6emn8agaj
Error during job execution (Bootstrap)
Execution exception (In /app/Bootstrap.java around line 10)
PersistenceException occured : org.hibernate.exception.SQLGrammarException: could not execute query
...
----------------------------------------
So it looks like the problem is caused by line 10 of Bootstrap.java where it's trying to access the User table. I'm using the minimalistic Bootstrap.java:
08 public void doJob() {
09 // Load default data if the database is empty
10 if(User.count() == 0) {
11 Fixtures.loadModels("initial-data.yml");
12 }
13 }
I don't know the details how bootstrap data is loaded. I assume the in-memory tables are created by the bootstrap process. Is it possible that when running play as a war file, the bootstrap code is not executed? If this is indeed causing the problem, is there a workaround?
Thanks in advance!
Jack