Search code examples
javamysqlspring-bootamazon-rdsliquibase

ClassCastException after upgrading AWS RDS MySQL


We have a Spring boot Web application where spring boot version is 1.5.6. After upgrading the AWS MySQL RDS to 8.0.28 from 5.7.0 we are getting liquibase error. I have upgraded the MySQL connector dependency to version 8.0.34 and liquibase-core version to 3.7.0 in pom.xml.

<dependency>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-core</artifactId>
    <version>3.7.0</version>
</dependency>
<dependency>
    <groupId>com.mysql</groupId>
    <artifactId>mysql-connector-j</artifactId>
    <version>8.0.34</version>
</dependency>

I have added changed the driver class name and hibernate dialect

spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect

I am getting error

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.ClassCastException: java.time.LocalDateTime cannot be cast to java.lang.String

When I use liquibase version greater than 4 I am getting another error Exception in thread "main" java.lang.NoClassDefFoundError: liquibase/servicelocator/CustomResolverServiceLocator at org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener$LiquibasePresent.replaceServiceLocator(LiquibaseServiceLocatorApplicationListener.java:54) at org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener.onApplicationEvent(LiquibaseServiceLocatorApplicationListener.java:44) Please help me to resolve that issue


Solution

  • I have resolved this issue by upgrading the MySQL version to 8.0.22 and Liquibase-core version to 3.10.0