StackOverflowError in CompositeClassLoader.getResources() when using liquibase commandline tool

Hi,

I am trying to use the liquibase commandline tool for the first time. I’m encountering a StackOverflowError.

This is the command I am running:
./liquibase --url='jdbc:postgresql://localhost:5432/postgres' --username=postgres --password=xxx --changeLogFile="nonexistent_file.xml" --referenceUrl="hibernate:classic:hibernate.cfg.xml" --diffTypes=data --logLevel=warning diffChangeLog

And here is what happens:

    17:58:05.120 INFO  [liquibase.integration.commandline.Main]: Liquibase Community 3.10.1 by Datical
    17:58:05.866 ERROR [liquibase.integration.commandline.Main]: Unexpected error running Liquibase: liquibase.exception.DatabaseException: java.lang.StackOverflowError
liquibase.exception.DatabaseException: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: java.lang.StackOverflowError
        at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:126)
        at liquibase.integration.commandline.Main.createReferenceDatabaseFromCommandParams(Main.java:1903)
        at liquibase.integration.commandline.Main.doMigration(Main.java:1417)
        at liquibase.integration.commandline.Main.run(Main.java:300)
        at liquibase.integration.commandline.Main.main(Main.java:159)
Caused by: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: java.lang.StackOverflowError
        at liquibase.ext.hibernate.database.HibernateDatabase.setConnection(HibernateDatabase.java:89)
        at liquibase.database.DatabaseFactory.findCorrectDatabaseImplementation(DatabaseFactory.java:129)
        at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:149)
        at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:91)
        ... 4 common frames omitted
Caused by: liquibase.exception.DatabaseException: java.lang.StackOverflowError
        at liquibase.ext.hibernate.database.HibernateDatabase.buildMetadataFromPath(HibernateDatabase.java:174)
        at liquibase.ext.hibernate.database.HibernateClassicDatabase.buildMetadataFromPath(HibernateClassicDatabase.java:39)
        at liquibase.ext.hibernate.database.HibernateDatabase.buildMetadata(HibernateDatabase.java:145)
        at liquibase.ext.hibernate.database.HibernateDatabase.setConnection(HibernateDatabase.java:85)
        ... 7 common frames omitted
Caused by: java.lang.StackOverflowError: null
        at java.base/java.lang.String.startsWith(String.java:1470)
        at java.base/java.net.URL.isBuiltinStreamHandler(URL.java:1639)
        at java.base/java.net.URL.isBuiltinStreamHandler(URL.java:1634)
        at java.base/java.net.URLStreamHandler.setURL(URLStreamHandler.java:517)
        at java.base/java.net.URLStreamHandler.parseURL(URLStreamHandler.java:312)
        at java.base/sun.net.www.protocol.file.Handler.parseURL(Handler.java:67)
        at java.base/java.net.URL.<init>(URL.java:674)
        at java.base/java.net.URL.<init>(URL.java:541)
        at java.base/jdk.internal.loader.URLClassPath$FileLoader.getResource(URLClassPath.java:1219)
        at java.base/jdk.internal.loader.URLClassPath$FileLoader.findResource(URLClassPath.java:1208)
        at java.base/jdk.internal.loader.URLClassPath$1.next(URLClassPath.java:341)
        at java.base/jdk.internal.loader.URLClassPath$1.hasMoreElements(URLClassPath.java:351)
        at java.base/java.net.URLClassLoader$3$1.run(URLClassLoader.java:687)
        at java.base/java.net.URLClassLoader$3$1.run(URLClassLoader.java:685)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.base/java.net.URLClassLoader$3.next(URLClassLoader.java:684)
        at java.base/java.net.URLClassLoader$3.hasMoreElements(URLClassLoader.java:709)
        at java.base/java.lang.CompoundEnumeration.next(ClassLoader.java:3032)
        at java.base/java.lang.CompoundEnumeration.hasMoreElements(ClassLoader.java:3041)
        at liquibase.resource.CompositeResourceAccessor$CompositeClassLoader.getResources(CompositeResourceAccessor.java:120)
        at liquibase.resource.CompositeResourceAccessor$CompositeClassLoader.getResources(CompositeResourceAccessor.java:130)
        at liquibase.resource.CompositeResourceAccessor$CompositeClassLoader.getResources(CompositeResourceAccessor.java:130)
        at liquibase.resource.CompositeResourceAccessor$CompositeClassLoader.getResources(CompositeResourceAccessor.java:130)
        at liquibase.resource.CompositeResourceAccessor$CompositeClassLoader.getResources(CompositeResourceAccessor.java:130)
... and so on

Here is my hibernate.cfg.xml:

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>

        <property name = "hibernate.dialect">
            org.hibernate.dialect.PostgreSQLDialect
        </property>

        <property name = "hibernate.connection.driver_class">
            org.postgresql.Driver
        </property>

        <property name = "hibernate.connection.url">
            jdbc:postgresql://localhost:5432/postgres
        </property>

        <property name = "hibernate.connection.username">
            postgres
        </property>

        <property name = "hibernate.connection.password">
            xxx
        </property>

    </session-factory>
</hibernate-configuration>

I have also tried it with an existing changelog.xml file containing

<changeSet  author="liquibase-docs"  id="empty-example">
    <empty/>
</changeSet>

which did not seem to help.

I’m using the following dependencies:

"org.postgresql:postgresql:42.2.14",
"org.liquibase:liquibase-core:jar:3.10.1",
"org.liquibase.ext:liquibase-hibernate5:jar:3.10.1",
"org.springframework:spring-core:jar:5.2.7.RELEASE",
"org.springframework:spring-beans:jar:5.2.7.RELEASE",

If anyone knows what is causing this, I would appreciate it very much.

Hi @bancron!

I see you are using the commandline for liquibase to run:

Is your changelog file actually called: nonexistent_file.xml?

If yes, please post the contents?

Hi @ronak,

No, the file doesn’t exist. I see now that I was running the wrong command, and generateChangeLog works without this error.

I think it would be helpful to print an error rather than having a StackOverflow for a nonexistent file.

Thanks!

1 Like

Hi @bancron, I agree! Internally I have logged a bug LB-390 to check for existense of the file specified in --changeLogFile and to give an explicit error that it cannot find the file if it does not exist.

Happy you are back and running.