Problem deploying war on Ubuntu server 16.04 + Tomcat 8.5 + MySQL

Hi, I have a problem trying to deploy an app-core.war.
Here is my gradle task:

task buildWar(type: CubaWarBuilding) {
    coreContextXmlPath = 'modules/core/web/META-INF/war-context.xml'
    appHome = '${catalina.base}/work'
    singleWar = false
    includeContextXml = true
    includeJdbcDriver = true
    appProperties = ['cuba.automaticDatabaseUpdate': false]
}

As you could see I don’t want my application to automatically update the db. The database has been copied from my development computer and I can connect to db locally using the same credentials.
Nevertheless the app-core fails to start with the error ‘Database update failed’. Sounds weird as I’m not asking to do the update. Probably the problem is more generic.
I’m a noob in Linux and can’t identify the problem myself. Please point me to the right direction.
Here is a content of localhost.2019-03-04.log file:

04-Mar-2019 12:49:59.685 INFO [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed()
04-Mar-2019 12:49:59.685 INFO [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed()
04-Mar-2019 12:50:10.800 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
04-Mar-2019 12:50:10.800 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()
04-Mar-2019 12:50:10.801 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: attributeAdded('StockTicker', 'async.Stockticker@532bde4d')
04-Mar-2019 12:51:12.913 INFO [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath
04-Mar-2019 12:51:16.597 SEVERE [localhost-startStop-2] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [com.haulmont.cuba.core.sys.AppContextLoader]
 java.lang.RuntimeException: 
=================================================
ERROR: Database update failed. See details below.
=================================================
Error loading executed scripts
	at com.haulmont.cuba.core.sys.dbupdate.DbUpdaterEngine.getExecutedScripts(DbUpdaterEngine.java:323)
	at com.haulmont.cuba.core.sys.dbupdate.DbUpdaterEngine.findUpdateDatabaseScripts(DbUpdaterEngine.java:105)
	at com.haulmont.cuba.core.sys.dbupdate.DbUpdaterImpl.checkDatabaseOnStart(DbUpdaterImpl.java:106)
	at com.haulmont.cuba.core.sys.dbupdate.DbUpdaterImpl.applicationInitialized(DbUpdaterImpl.java:81)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:256)
	at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:177)
	at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:140)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
	at com.haulmont.cuba.core.sys.EventsImpl.publish(EventsImpl.java:33)
	at com.haulmont.cuba.core.sys.AbstractAppContextLoader.initAppContext(AbstractAppContextLoader.java:66)
	at com.haulmont.cuba.core.sys.AbstractWebAppContextLoader.contextInitialized(AbstractWebAppContextLoader.java:77)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4776)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5240)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)
	at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1856)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.sql.SQLException: Table 'gs1_nz.SYS_DB_CHANGELOG' doesn't exist Query: select SCRIPT_NAME from SYS_DB_CHANGELOG Parameters: []
	at com.haulmont.bali.db.QueryRunner.rethrow(QueryRunner.java:462)
	at com.haulmont.bali.db.QueryRunner.query(QueryRunner.java:320)
	at com.haulmont.bali.db.QueryRunner.query(QueryRunner.java:411)
	at com.haulmont.bali.db.QueryRunner.query(QueryRunner.java:386)
	at com.haulmont.bali.db.QueryRunner.query(QueryRunner.java:430)
	at com.haulmont.cuba.core.sys.dbupdate.DbUpdaterEngine.getExecutedScripts(DbUpdaterEngine.java:312)
	... 31 more

04-Mar-2019 12:51:16.603 SEVERE [localhost-startStop-2] org.apache.catalina.core.StandardContext.listenerStop Exception sending context destroyed event to listener instance of class [com.haulmont.cuba.core.sys.AppContextLoader]
 java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
	at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:170)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1092)
	at com.haulmont.cuba.core.sys.AbstractWebAppContextLoader.contextDestroyed(AbstractWebAppContextLoader.java:105)
	at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4823)
	at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5462)
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)
	at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1856)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748) 

Hi Rimantas,

When cuba.automaticDatabaseUpdate is false, the app tries to check whether all update scripts are executed on the current database. If not, a warning is printed to the log, which is a signal for developer to turn on automatic update on startup.
Your database does not have the SYS_DB_CHANGELOG table for some reason. This table normally contains the list of executed scripts, and it is needed for the check.

Regards,
Konstantin

Thanks for you reply. As I’ve stated the database on the server is a copy of the database on my development computer. The table SYS_DB_CHANGELOG exists and is full of records.
Anyway I think I’ve figured out the cause of the error. Since the development database has been created on the Windows computer, all table names are in lowercase. But select statement uses table names in uppercase.
That’s really confusing.

Try to setup lower_case_table_names parameter as described in the MySQL documentation.

1 Like

Thanks, didn’t know that.