Hi everyone,
currently we have a problem using Liquibase and WebSphere 6.1. We get ClassCastExceptions like this:
java.lang.ClassCastException: liquibase.statement.core.CreateIndexStatement incompatible with liquibase.statement.core.DropPrimaryKeyStatement
at liquibase.sqlgenerator.core.DropPrimaryKeyGenerator.supports(DropPrimaryKeyGenerator.java:12)
at liquibase.sqlgenerator.SqlGeneratorFactory.checkType(SqlGeneratorFactory.java:120)
at liquibase.sqlgenerator.SqlGeneratorFactory.getGenerators(SqlGeneratorFactory.java:95)
at liquibase.sqlgenerator.SqlGeneratorFactory.supports(SqlGeneratorFactory.java:155)
at liquibase.change.AbstractChange.warn(AbstractChange.java:79)
at liquibase.changelog.visitor.ValidatingVisitor.visit(ValidatingVisitor.java:77)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
at liquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:131)
at liquibase.Liquibase.listUnrunChangeSets(Liquibase.java:583)
After some debugging I found out that this is caused by this expressionin the checkType method of SqlGeneratorFactory:
if (typeClass.equals(SqlStatement.class)) {
Looks like WebSphere uses multiple classloaders, so there are multiple definitions of SqlStatements loaded. Although typeClass is SqlStatement, sometimes the expression returns false.
Later the ClassCastException occurs.
Is it possible to migrate the code not to use the equals method? I think you don’t want to compare the type (hierachy) of the class and not the instance itself, don’t you?
I have to admit we don’t have this problem on every WebSphere environment, but from time to time it occurs…
Kind regards
Oliver
-
Learn
-
Resources
-
Free Tools
OSS Risk Scanner Database DevOps Risk AssessmentCheat Sheets
Snowflake + Liquibase Databricks + Liquibase -
eBooks
6 Liquibase Community Risks & How to Avoid Guide: SOC 2 Compliance at the Database Layer Guide: Quantify the Value of Liquibase Secure -
Comparison Guides
Liquibase vs. Flyway Liquibase vs. Bytebase Liquibase Community vs Liquibase Secure
-
- Quickstart
- Get Started
- Documentation
- University
-
Resources
- Connect
- Contribute
- Join
- Blog