Hi everyone,
we have a tricky error after upgrading our H2-dependency to version 2.1.212. Our Liquibase Version is 4.11.0.
We use H2 in our spring boot tests. After the upgrade we experience that every time the application test context is build up new (for example if a test uses a mockbean) the drop of the schema by liquibase fails.
Our application properties that are used in the tests are:
swagger.json.location=openapi/openapi.json swagger.json.location=openapi/openapi.json
test database
spring.datasource.url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;CASE_INSENSITIVE_IDENTIFIERS=TRUE;DB_CLOSE_ON_EXIT=false;INIT=CREATE SCHEMA IF NOT EXISTS test\\;SET SCHEMA test;MODE=MySQL;DATABASE_TO_LOWER=TRUE
spring.datasource.username=sa
spring.datasource.password=
database dialect
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=validate
Liquibase
spring.liquibase.default-schema=test
spring.liquibase.liquibase-schema=test
spring.liquibase.user=sa
spring.liquibase.password=
spring.liquibase.drop-first=true
spring.liquibase.parameters.appDbUser=sa
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
We debugged a lot and we saw that the error is happening at the drop of the old schema at the "StandardLockService"
This leads to the following error:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.DatabaseException: liquibase.exception.CommandExecutionException: java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:144)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
... 27 more
Caused by: liquibase.exception.DatabaseException: liquibase.exception.CommandExecutionException: java.lang.NullPointerException
at liquibase.Liquibase.dropAll(Liquibase.java:1833)
at liquibase.Liquibase.dropAll(Liquibase.java:1810)
at liquibase.integration.spring.SpringLiquibase.createLiquibase(SpringLiquibase.java:330)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:267)
at org.springframework.boot.autoconfigure.liquibase.DataSourceClosingSpringLiquibase.afterPropertiesSet(DataSourceClosingSpringLiquibase.java:46)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
... 44 more
Caused by: liquibase.exception.CommandExecutionException: java.lang.NullPointerException
at liquibase.command.CommandScope.execute(CommandScope.java:163)
at liquibase.Liquibase.dropAll(Liquibase.java:1831)
... 50 more
Caused by: java.lang.NullPointerException
at liquibase.diff.output.changelog.ChangeGeneratorFactory.fixUnexpected(ChangeGeneratorFactory.java:102)
at liquibase.lockservice.StandardLockService.destroy(StandardLockService.java:489)
at liquibase.command.core.InternalDropAllCommandStep.run(InternalDropAllCommandStep.java:118)
at liquibase.command.CommandScope.execute(CommandScope.java:157)
... 51 more
Did anyone experience this before?