javaspring-bootliquibaseliquibase-sql

Liquibase with Spring Boot and SQL Server throwing error NoClassDefFOundError for class SnowflakeDatabase


My Spring Boot application is using local SQL server database is failing on startup with error below.

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 java.lang.NoClassDefFoundError: liquibase/database/core/SnowflakeDatabase
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.22.jar:5.3.22]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.22.jar:5.3.22]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.22.jar:5.3.22]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.2.jar:2.7.2]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.2.jar:2.7.2]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.2.jar:2.7.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.2.jar:2.7.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.2.jar:2.7.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.2.jar:2.7.2]
    at com.musala.notification.NotificationApplication.main(NotificationApplication.java:10) ~[classes/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.7.2.jar:2.7.2]
Caused by: java.lang.NoClassDefFoundError: liquibase/database/core/SnowflakeDatabase
    at com.datical.liquibase.ext.storedlogic.storedproc.SnowflakeStoredProcedureSnapshotGenerator.getPriority(Unknown Source) ~[liquibase-commercial-4.17.0.jar:na]
    at liquibase.snapshot.SnapshotGeneratorFactory.getGenerators(SnapshotGeneratorFactory.java:84) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.snapshot.SnapshotGeneratorFactory.getContainerTypes(SnapshotGeneratorFactory.java:306) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.snapshot.SnapshotGeneratorFactory.getContainerTypes(SnapshotGeneratorFactory.java:290) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.snapshot.SnapshotGeneratorFactory.has(SnapshotGeneratorFactory.java:101) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.snapshot.SnapshotGeneratorFactory.hasDatabaseChangeLogLockTable(SnapshotGeneratorFactory.java:279) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.lockservice.StandardLockService.hasDatabaseChangeLogLockTable(StandardLockService.java:229) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.lockservice.StandardLockService.init(StandardLockService.java:113) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.lockservice.StandardLockService.acquireLock(StandardLockService.java:286) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.lockservice.StandardLockService.waitForLock(StandardLockService.java:247) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.Liquibase.lambda$update$1(Liquibase.java:214) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.Scope.lambda$child$0(Scope.java:180) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.Scope.child(Scope.java:189) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.Scope.child(Scope.java:179) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.Scope.child(Scope.java:158) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.Liquibase.runInScope(Liquibase.java:2405) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.Liquibase.update(Liquibase.java:211) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.Liquibase.update(Liquibase.java:197) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:314) ~[liquibase-core-4.9.1.jar:na]
    at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:269) ~[liquibase-core-4.9.1.jar:na]
    at org.springframework.boot.autoconfigure.liquibase.DataSourceClosingSpringLiquibase.afterPropertiesSet(DataSourceClosingSpringLiquibase.java:46) ~[spring-boot-autoconfigure-2.7.2.jar:2.7.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.22.jar:5.3.22]
    ... 23 common frames omitted
Caused by: java.lang.ClassNotFoundException: liquibase.database.core.SnowflakeDatabase
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]
    ... 46 common frames omitted

application.properties

#
#Liquibase properties
#
spring.liquibase.enabled=true
spring.liquibase.change-log=classpath:db.changelog-base.yaml
spring.liquibase.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.liquibase.url=jdbc:sqlserver://localhost:1434;databaseName=NG1;encrypt=true;trustServerCertificate=true
spring.liquibase.user=sa
spring.liquibase.password=P@ssw0rd
spring.liquibase.liquibase-schema=NOTIFICATION

pom.xml dependency

<dependency>
   <groupId>org.liquibase</groupId>
   <artifactId>liquibase-core</artifactId>
</dependency>

My changelog files are <>-mssql.sql.

db.changelog-base.yaml is in resource folder

databaseChangeLog:
  - includeAll:
      path: db/changelog/

I was wandering why I it is searching for snowflake database? Because I am using SQL Server. It will be great if I can get a solution for this issue.

A solution or root cause to fix this.


Solution

  • We solved this issue by setting the liquibase-core version to 4.15.0.