Search code examples
javaliquibase

InvocationTargetException upgrading liquibase from 4.11.0 to any newer version available


I am upgrading my liquibase version from 4.11.0 to 4.24.0 and while running the integration tests there is an error and eventually ends up with Stackoverflow error. It is trying to get an instance of DatabaseFactory (DatabaseFactory.getInstance()) and throws this error. The stack trace of the exception

java.lang.RuntimeException: liquibase.exception.UnexpectedLiquibaseException: java.lang.reflect.InvocationTargetException
at liquibase.database.DatabaseFactory.<init>(DatabaseFactory.java:43)
at liquibase.database.DatabaseFactory.getInstance(DatabaseFactory.java:50)  Caused by: liquibase.exception.UnexpectedLiquibaseException: java.lang.reflect.InvocationTargetException
at liquibase.Scope.getSingleton(Scope.java:343)
at liquibase.configuration.LiquibaseConfiguration.getCurrentConfiguredValue(LiquibaseConfiguration.java:147)
at liquibase.configuration.ConfigurationDefinition.getCurrentConfiguredValue(ConfigurationDefinition.java:106)
at liquibase.configuration.ConfigurationDefinition.getCurrentConfiguredValue(ConfigurationDefinition.java:90)
at liquibase.configuration.ConfigurationDefinition.getCurrentValue(ConfigurationDefinition.java:64)
at liquibase.configuration.GlobalConfiguration.getOutputEncoding(GlobalConfiguration.java:308)
at liquibase.servicelocator.DefaultPackageScanClassResolver.findAllClasses(DefaultPackageScanClassResolver.java:159)
at liquibase.servicelocator.DefaultPackageScanClassResolver.find(DefaultPackageScanClassResolver.java:126)
at liquibase.servicelocator.DefaultPackageScanClassResolver.findImplementations(DefaultPackageScanClassResolver.java:94)
at liquibase.servicelocator.ClasspathScanningServiceLocator.searchForImplementations(ClasspathScanningServiceLocator.java:133)
at liquibase.servicelocator.ClasspathScanningServiceLocator.findInstances(ClasspathScanningServiceLocator.java:110)
at liquibase.database.DatabaseFactory.<init>(DatabaseFactory.java:39)
... 33 more Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at liquibase.Scope.getSingleton(Scope.java:340)

Are there any changes to API that should be included or any dependencies that should be included. I have tried with 4.26.0 as well and this is the same error. Any help would be much appreciated.

Thanks.


Solution

  • After debugging the code and backtracking the release notes for various releases, i found the solution, Need to add this dependency to fix this error.

    <dependency>
      <groupId>org.liquibase</groupId>
      <artifactId>liquibase-commercial</artifactId>
      <version>4.24.0</version>
      <scope>test</scope>
    </dependency>
    

    As per the release notes for 4.14.0

    **Notable Changes**    
    "Split liquibase-core and liquibase-commercial jar files in #3050
        
        This change affects new downloads of Liquibase Pro. liquibase-core-.jar contains only the open-source license. If you use Liquibase Pro or other commercial add-ons, you must also install liquibase-commercial-.jar."