question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

changelog is found twice in classpath

See original GitHub issue

Environment

This is potentially a duplicate of https://github.com/liquibase/liquibase/issues/1916 / https://github.com/liquibase/liquibase/issues/1916#issuecomment-1116361306, but since that’s closed, I’m opening a new issue.

Liquibase Version: 4.0.0, 4.1.0, 4.3.2, 4.3.3, 4.3.4, 4.3.5, 4.4.0, 4.4.1, 4.4.2, 4.4.3, 4.5.0, 4.6.0, 4.6.1, 4.6.2, 4.7.0, 4.7.1, 4.8.0, 4.9.0, and 4.9.1 Liquibase Integration & Version: gradle, spring boot 2.2.13, 2.3.12

Liquibase Extension(s) & Version:

Database Vendor & Version:

Operating System Type & Version:

Description

liquibase throws an exception that a changelog file is on the classpath twice. Here’s the stacktrace from liquibase 4.9.1:

Caused by: liquibase.exception.ChangeLogParseException: Error parsing classpath:db/healthcheck.yml
	at liquibase.parser.core.yaml.YamlChangeLogParser.parse(YamlChangeLogParser.java:89)
	at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:369)
	at liquibase.Liquibase.lambda$update$1(Liquibase.java:224)
	at liquibase.Scope.lambda$child$0(Scope.java:180)
	at liquibase.Scope.child(Scope.java:189)
	at liquibase.Scope.child(Scope.java:179)
	at liquibase.Scope.child(Scope.java:158)
	at liquibase.Liquibase.runInScope(Liquibase.java:2405)
	at liquibase.Liquibase.update(Liquibase.java:211)
	at liquibase.Liquibase.update(Liquibase.java:197)
	at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:314)
	at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:269)
	at com.netflix.spinnaker.kork.sql.migration.SpringLiquibaseProxy.afterPropertiesSet(SpringLiquibaseProxy.kt:65)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1858)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1795)
	... 87 more
Caused by: java.io.IOException: Found 2 files that match classpath:db/healthcheck.yml: file:/Users/dbyron/src/spinnaker/kork/kork-sql/build/resources/main/db/healthcheck.yml, jar:file:/Users/dbyron/src/spinnaker/kork/kork-sql/build/libs/kork-sql.jar!/db/healthcheck.yml
	at liquibase.resource.AbstractResourceAccessor.openStream(AbstractResourceAccessor.java:25)
	at liquibase.parser.core.yaml.YamlChangeLogParser.parse(YamlChangeLogParser.java:25)
	... 101 more

Steps To Reproduce

This happens in kork, with:

$ ./gradlew kork-sql:test

I tried adding a test to SpringResourceAccessorTest.groovy, but I’m not familiar enough with mvn to get a test to run after packaging the jar, so it passes. I believe the mvn terminology for the kind of test I’m looking for is an integration test.

    def "openStreams for a file in src/main/resources"() {
        when:
        def list = resourceAccessor.openStreams(null, "classpath:/liquibase/examples/yaml/example-changelog.yaml")

        then:
        list.size() == 1
    }

I believe this commit is the one that made this stop working in 4.3.2, when it worked in 4.3.1, specifically the change to finalizeSearchPath that unconditionally prepends classpath*:.

I single-stepped through SpringResourceAccessor.openStreams. In 4.3.1, the return value from

ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources(searchPath);

is an array with one classpath resource element. searchPath in this case is classpath:db/healthcheck.yml. In 4.3.2 though, searchPath is classpath*:/db/healthcheck.yml and the return value is (perhaps obviously) an array with two elements:

          URL [file:/Users/dbyron/src/spinnaker/kork/kork-sql/build/resources/main/db/healthcheck.yml]
          URL [jar:file:/Users/dbyron/src/spinnaker/kork/kork-sql/build/libs/kork-sql.jar!/db/healthcheck.yml]

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:27 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
marcelstoercommented, Sep 19, 2022

@kataggart thanks, had planned on doing so anyway: #3282. Also stated there why #3119 is not applicable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set liquibase classpath - Stack Overflow
I would like to run the liquibase changesets manually. By default the changesets are included from the classpath. The changelog is in src/main/ ......
Read more >
Error Reading Changelog File: Found 2 files that match
We have changelog files that have file names with german letters. Before we use liquibase version 3.10.2, there is no problem.
Read more >
From Version 4.3.2 on change-log file is found twice in classpath
Building and starting the jar with gradle still works. ... After downgrading to liquibase 4.3.1 everything works fine. See More. View in GitHub....
Read more >
Apache Tomcat 9 (9.0.70) - Changelog
Refactor the resource files for the Apache Tomcat installer for Windows so that all the resource files are located in a single directory...
Read more >
logback.xml being picked up twice in project (how do I surpess ...
LoggerContext[default] - Found resource [logback.xml] at ... Resource [logback.xml] occurs multiple times on the classpath.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found