# LiquibaseException java.lang.ClassCastException: class java.time.LocalDateTime cannot be cast to class java.lang.String

**URL:** <https://forum.liquibase.org/t/liquibaseexception-java-lang-classcastexception-class-java-time-localdatetime-cannot-be-cast-to-class-java-lang-string/5059>\
**Category:** Liquibase Development\
**Created:** [February 12, 2021, 3:20pm UTC](https://forum.liquibase.org/t/liquibaseexception-java-lang-classcastexception-class-java-time-localdatetime-cannot-be-cast-to-class-java-lang-string/5059 "2021-02-12T15:20:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![diana](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@diana](https://forum.liquibase.org/u/diana)\
**Post date:** [February 12, 2021, 3:20pm UTC](https://forum.liquibase.org/t/liquibaseexception-java-lang-classcastexception-class-java-time-localdatetime-cannot-be-cast-to-class-java-lang-string/5059/1 "2021-02-12T15:20:07Z")

</div>

Hello,

we are getting error with last version to mysql-connector-java (8.0.23) and liquibase(4.3.0), when we start the spring boot application. The error started when we updated mysql-connector-java (8.0.22) to mysql-connector-java (8.0.23). Looks like error with DATABASECHANGELOG table, DATEEXECUTED field.

nested exception is 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.LiquibaseException: java.lang.ClassCastException: class java.time.LocalDateTime cannot be cast to class java.lang.String (java.time.LocalDateTime and java.lang.String are in module java.base of loader ‘bootstrap’)

---

<div class="post-metadata">

**Author:** ![1o2](https://avatars.discourse-cdn.com/v4/letter/1/22d042/32.png) [@1o2](https://forum.liquibase.org/u/1o2)\
**Post date:** [February 24, 2021, 10:37am UTC](https://forum.liquibase.org/t/liquibaseexception-java-lang-classcastexception-class-java-time-localdatetime-cannot-be-cast-to-class-java-lang-string/5059/2 "2021-02-24T10:37:03Z")

</div>

We have the same problem. And it’s even more interesting because if you run your change log file first time everything is great. But after databasechangelog table created it stops working.  
Have you find a solution?

---

<div class="post-metadata">

**Author:** ![diana](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@diana](https://forum.liquibase.org/u/diana)\
**Post date:** [February 24, 2021, 10:54am UTC](https://forum.liquibase.org/t/liquibaseexception-java-lang-classcastexception-class-java-time-localdatetime-cannot-be-cast-to-class-java-lang-string/5059/3 "2021-02-24T10:54:49Z")

</div>

Hello,

found solution switching to liquibase 4.3.1 version.

---

<div class="post-metadata">

**Author:** ![1o2](https://avatars.discourse-cdn.com/v4/letter/1/22d042/32.png) [@1o2](https://forum.liquibase.org/u/1o2)\
**Post date:** [February 24, 2021, 12:13pm UTC](https://forum.liquibase.org/t/liquibaseexception-java-lang-classcastexception-class-java-time-localdatetime-cannot-be-cast-to-class-java-lang-string/5059/5 "2021-02-24T12:13:35Z")

</div>

Thanks a lot. It’s worked out for me as well. I guess it was kind of a bug.

---

<div class="post-metadata">

**Author:** ![artem.boiarshinov](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/artem.boiarshinov/32/346_2.png) [@artem.boiarshinov](https://forum.liquibase.org/u/artem.boiarshinov)\
**Post date:** [March 14, 2021, 8:21am UTC](https://forum.liquibase.org/t/liquibaseexception-java-lang-classcastexception-class-java-time-localdatetime-cannot-be-cast-to-class-java-lang-string/5059/6 "2021-03-14T08:21:49Z")

</div>

I have exactly the same issue with liquibase-core v.3.10.3 and mysql-connector-java v.8.0.23.  
Migrating to liquibase-core v.4.3.1 solved the problem.

---

<div class="post-metadata">

**Author:** ![andrey\_delay](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@andrey\_delay](https://forum.liquibase.org/u/andrey_delay)\
**Post date:** [May 16, 2021, 12:37pm UTC](https://forum.liquibase.org/t/liquibaseexception-java-lang-classcastexception-class-java-time-localdatetime-cannot-be-cast-to-class-java-lang-string/5059/7 "2021-05-16T12:37:01Z")

</div>

For me working as well v.4.3.1. Thanks for the solution!

---

<div class="post-metadata">

**Author:** ![S.Smith](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@S.Smith](https://forum.liquibase.org/u/S.Smith)\
**Post date:** [June 13, 2021, 4:02pm UTC](https://forum.liquibase.org/t/liquibaseexception-java-lang-classcastexception-class-java-time-localdatetime-cannot-be-cast-to-class-java-lang-string/5059/8 "2021-06-13T16:02:58Z")

</div>

In case someone else runs into this issue, and if your project allows for the downgrade, you may try downgrading the jdbc driver used. I hit this error and reverted to use jdbc version 8.0.22 when I was using 8.0.25.

---

<div class="post-metadata">

**Author:** ![pedrocastineiras](https://avatars.discourse-cdn.com/v4/letter/p/ed655f/32.png) [@pedrocastineiras](https://forum.liquibase.org/u/pedrocastineiras)\
**Post date:** [August 10, 2021, 3:55pm UTC](https://forum.liquibase.org/t/liquibaseexception-java-lang-classcastexception-class-java-time-localdatetime-cannot-be-cast-to-class-java-lang-string/5059/9 "2021-08-10T15:55:56Z")

</div>

Thanks Diana, that worked for me too.

---

<div class="post-metadata">

**Author:** ![benjaminzx](https://avatars.discourse-cdn.com/v4/letter/b/c68b51/32.png) [@benjaminzx](https://forum.liquibase.org/u/benjaminzx)\
**Post date:** [July 15, 2022, 10:33pm UTC](https://forum.liquibase.org/t/liquibaseexception-java-lang-classcastexception-class-java-time-localdatetime-cannot-be-cast-to-class-java-lang-string/5059/10 "2022-07-15T22:33:46Z")

</div>

> [@diana](#):
>
> liquibase.exception.LiquibaseException: java.lang.ClassCastException:

The exaception thrown to indicate that your code has attempted to cast an object to a subclass of which it is not an instance. This means that ClassCastException occurs when you try to cast an instance of an Object to a type that it is not. [Type Casting](http://net-informations.com/java/basics/casting.htm) 5 only works when the casted object follows an is a relationship to the type you are trying to cast to.

It is good practice to guard any explicit casts with an instanceof check first:

```auto
if (myApple instanceof Fruit) {
  Fruit myFruit = (Fruit)myApple;
}

```

When will be ClassCastException is thrown:

- When you try to cast an object of Parent class to its Child class type, this exception will be thrown.

- When you try to cast an object of one class into another class type that has not extended the other class or they don’t have any relationship between them
