Adding domain class causes deploy to fail

14 views
Skip to first unread message

Jorge Barrionuevo

unread,
May 27, 2019, 3:41:09 PM5/27/19
to Grails Dev Discuss
Hi everyone,

I'm working with a Grails 2.0.4 legacy application. Adding a new (empty) domain class to the project causes Tomcat to fail to deploy the WAR.

Scenario
-The domain class is created with grails create-domain-class com.company.group..ClassName
-The class needs to be mapped in a MySQL table, as the rest of the domain classes.
-Tried both creating the MySQL table manually and not creating it at all. 
-ORM is Hibernate 2.0.4 
-Tomcat log catalina.out doesn't show any error, despite failure to deploy the war.
-Deleting the new domain class will cause the WAR to be deployed properly.

Help will be appreciated. Thanks!

Daniel Leahy

unread,
May 27, 2019, 3:57:04 PM5/27/19
to grails-de...@googlegroups.com
Hi Jorge,


Grails 2.0.4, wow that's going back a while.

Could be a lot of different things

What is your dbCreate flag set for production?

For production, it should be set to none, but you could set it to update

Does the DB user in the datasource config your using have permission to create new tables?

I use flyway for Db migrations, liquibase is also an alternative, or manually doing it.

If you have a local instance of the DB, you can install the war in a local instance of tomcat with the dbCreate flag set  to create-drop and see does it create the new domain/schema for you in the DB.

Docker is an excellent way to recreate the infrastructure you need to run the app locally.

If it does you can then get your DB tool, MySQL workbench or pgadmin3 or whatever tool to create the creation script for the new table which you can then run against the production DB to update it.

You can also turn on SQL logging in your data source config to see what SQL is being attempted.

Regards, 
                Daniel Leahy.













--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.
To post to this group, send email to grails-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/1d2cf67f-5716-402b-b576-f595227731e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jorge Barrionuevo

unread,
May 28, 2019, 8:40:18 AM5/28/19
to grails-de...@googlegroups.com
Hi Daniel,

Found the dbCreate flag is in a file located in the server, that overrides the Grails environment configuration. It was set as "validate". As you suggested, changed the value to "Update" and it started pulling the data from the MySQL table.

Thanks! I really appreciate your help.


Daniel Leahy

unread,
May 28, 2019, 8:56:49 AM5/28/19
to Grails Dev Discuss
Hi Jorge, 
               now that you got your app working again on production I would highly recommend you set the dbCreate flag back to validate or none for production

It is just best practice not to have the grails-app change your DB schema in production.

best practice would be to use flyway or liquibase to handle your Db migrations so you can see the delta changes over time and have the possibility of rolling back automatically if a change didn't work.

Best of luck,
                   Daniel Leahy.








To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-discuss+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-discuss+unsub...@googlegroups.com.

Jorge Barrionuevo

unread,
May 28, 2019, 9:24:21 AM5/28/19
to grails-de...@googlegroups.com
I'm working in a development environment. Will definitely consider a DB versioning system. Thanks.

There is something you mentioned that is interesting. As I am working with this legacy mid sized monolithic web application (all layers deployed as a single WAR) and the development and test process involve several steps to get a version to the DEV environment (compile, build, move to the cloud, un-deploy and deploy), I was thinking on the best approach to make a repeatable local environment to reduce these lengthy cycles. An option would be to have a Docker container (with a Tomcat) where we could modify, compile, build and Deploy the Grails app. Then a second container for the DB (or a local instance). Not sure if that would be a good approach.

Thanks again!     

Best regards,

To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.

To post to this group, send email to grails-de...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages