Fwd: Bootstrap error when running Play! 1.2.x war file in tomcat

127 views
Skip to first unread message

jlist9

unread,
Jun 29, 2013, 8:43:56 PM6/29/13
to pla...@googlegroups.com
I originally sent this email to the play list. Maybe playone list is a better place to ask play 1.x questions. Sorry that some of you get it twice.

---------- Forwarded message ----------

Hi all,

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

Mariusz Nosiński

unread,
Jun 30, 2013, 4:58:34 PM6/30/13
to pla...@googlegroups.com
Hi, I didn't test it in tomcat but I answer your questions.

 
Is it possible that when running play as a war file, the bootstrap code is not executed?
Play don't recognize application is running as war file  at tomcat server, but you can check mode you are running in. For example you cant add "if(Play.isProd())" and put code that should be executed only in production state.  
 
If this is indeed causing the problem, is there a workaround?
Maybe you should use evolutions? I know, autocreation data tables is nice feature, but when you make it maual you have more control.


read about it. Maybe it help you.

best regards.
 

Thanks in advance!

Jack

Grzegorz Słowikowski

unread,
Jul 1, 2013, 3:12:47 AM7/1/13
to pla...@googlegroups.com, jlist9
Hi

Did you set "jpa.ddl" property? When running in "prod" mode default
value is "none" ("update" in "dev" mode).
When running in Tomcat, Play! is running in "prod" mode I think.
See: http://www.playframework.com/documentation/1.2.5/configuration#jpa
If your war profile is "war" (default), add:
%war.jpa.ddl=update
to your "application.conf" file.

Greetings

Grzegorz Slowikowski
> --
> You received this message because you are subscribed to the Google
> Groups "playone" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to playone+u...@googlegroups.com.
> To post to this group, send email to pla...@googlegroups.com.
> Visit this group at http://groups.google.com/group/playone.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

jlist9

unread,
Jul 1, 2013, 3:20:12 AM7/1/13
to pla...@googlegroups.com
Thank you Mariusz!

I guess most people are running Play! directly (without a container.) In my case I need to run another framework on the same server so I thought it would be easier to run two .war files on the same tomcat. Given the low (1) responses, I guess I'm off the beaten path. Maybe I'll run into fewer issues if I run a front end server, a separate Play! server and a tomcat server instead. It's not ideal because this means two more servers to manage. 

I'll take a look at evolution. Meanwhile, I'm thinking maybe I can run Play! standalone once in prod mode to get the databases created, then switch to running the war file. This way at least I can get it going initially. Future updates of the database may still be a problem? At this point I'm unclear about how auto-update, auto-create and evolution work exactly. So far I've only used auto-update (I think) in dev mode while running standalone play!. Is evolutions the recommebnded way for prod environment?

Another, but related, question is, is there a way to log the SQL commands in auto-update mode so that I know how Play created the tables so that I can manage the SQL commands manually if I need to?

Thanks,
Jack


mario

unread,
Jul 1, 2013, 3:37:42 AM7/1/13
to pla...@googlegroups.com
there is an property for manage database schema : jpa.ddl= you can set it to "none" if you want manage it manually, "create" if you want that framework create tables automatically but don't change it if you change models in application. And you can set it to "update" -> with this framework manage all changes made in code and create/update database schema (tables and relations).

just set up in your application "jpa.ddl=update" and you have nothing to do more. But you lost control over it, all will be managed by framework. 


2013/7/1 jlist9 <jli...@gmail.com>

--
You received this message because you are subscribed to a topic in the Google Groups "playone" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/playone/z89B6KvSybw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to playone+u...@googlegroups.com.

To post to this group, send email to pla...@googlegroups.com.
Visit this group at http://groups.google.com/group/playone.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
there are only 10 types of people in the world, those who understand binary and those who don't.

jlist9

unread,
Jul 1, 2013, 12:45:25 PM7/1/13
to pla...@googlegroups.com
BTW, "war" profile is used when deployed as a war file. Is this documented somewhere? Maybe I missed it.

jlist9

unread,
Jul 1, 2013, 12:46:53 PM7/1/13
to pla...@googlegroups.com
Thanks for explaining! Is there a way to log the command Play uses to create or update the table schema? I'm thinking this will be helpful when I try to manage the schema manually.

jlist9

unread,
Jul 2, 2013, 3:09:51 AM7/2/13
to pla...@googlegroups.com
For some reason I replied to Grzegorz instead of the list. 

With Mariusz and Grzegorz's help I was able to get pass the original database problem. Thanks for the help!

Then I ran into a new problem (see email below.) It turned out that it's a Java 1.7 problem. The problem went away after I switched to Java 1.6. There are quite a few reports of Secure module having problem with Java 1.7. This is an example:


Hope this is helpful to others.

Jack

---------- Forwarded message ----------

Thank you Grzegorz!

I didn't know that play could be running in prod mode. I just tried it (with Play.mode.isProd()) and found that it's indeed the case. I added "%war.jpa.ddl=update" as you suggested. Now Play is creating the database entries correctly.

Now I'm hitting another error (below) that has something to do with the secure module. This does not happen in dev mode. I'm not sure if it has to do with the users table yet but thanks for the help!

Caused by: java.lang.VerifyError: Expecting a stack map frame in method controllers.Secure$Security.
authentify(Ljava/lang/String;Ljava/lang/String;)Z at offset 33
        at controllers.BaseController.setConnectedUser(BaseController.java:22)
        at play.mvc.ActionInvoker.invoke(ActionInvoker.java:510)
        at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:484)
        at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:479)
        at play.mvc.ActionInvoker.handleBefores(ActionInvoker.java:328)
        at play.mvc.ActionInvoker.invoke(ActionInvoker.java:142)
        ... 22 more

Jack


On Mon, Jul 1, 2013 at 12:12 AM, Grzegorz Słowikowski <gslowi...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages