LiquibaseServletListener.contextInitialized() should not shut Embedded Derby down

Description

Using the Liquibase Servlet Listener integration with Embedded Derby I’m observing:

java.sql.SQLNonTransientConnectionException: No current connection

Using

(a Maven WAR project):

See:

src/main/webapp/META-INF/context.xml

The issue appears aided by the Tomcat JDBC Connection Pool default setup:

testOnBorrow

... Default value is false

vs. the default DBCP 2 (JNDI Datasource How-ToBasicDataSource Configuration Parameters):

Parameter

Default

testOnBorrow

true

The obvious workaround is to configure the Datasource to detect invalid connections immediately and reconnect which would reboot the Embedded Derby instance.

The workaround might be considered suboptimal (for performance reasons) and to avoid general confusion by the errors seen with some default settings, I think Liquibase should not shut Embedded Derby down in LiquibaseServletListener.contextInitialized() but possibly in LiquibaseServletListener.contextDestroyed() (as courtesy to the users):

https://github.com/liquibase/liquibase/blob/v3.8.2/liquibase-core/src/main/java/liquibase/integration/servlet/LiquibaseServletListener.java#L228

(At very least the documentation could be updated to give heads up on this issue.)

 

Environment

  • Java 1.8

  • Tomcat 8.5

  • Derby 10.4

Reporter

Stanimir Stamenkov

Affects versions

Priority

Minor
Configure