Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application fails to start on Docker native image: Cannot parse resource location: 'resource:/' #331

Open
averri opened this issue Feb 27, 2023 · 0 comments

Comments

@averri
Copy link

averri commented Feb 27, 2023

Expected Behavior

The Micronaut Liquibase should work as expected when running on GraalVM native Docker images.

Actual Behaviour

Micronaut Liquibase fails to start when running on a native image. This is the error:

19:23:42.277 [main] ERROR io.micronaut.runtime.Micronaut - Error starting Micronaut server: Bean definition [javax.sql.DataSource] could not be loaded: Migration failed! Liquibase encountered an exception.
2023-02-27T19:23:42.277734425Z io.micronaut.context.exceptions.BeanInstantiationException: Bean definition [javax.sql.DataSource] could not be loaded: Migration failed! Liquibase encountered an exception.
2023-02-27T19:23:42.277741785Z 	at io.micronaut.context.DefaultBeanContext.initializeContext(DefaultBeanContext.java:1921)
2023-02-27T19:23:42.277745586Z 	at io.micronaut.context.DefaultApplicationContext.initializeContext(DefaultApplicationContext.java:249)
2023-02-27T19:23:42.277747925Z 	at io.micronaut.context.DefaultBeanContext.readAllBeanDefinitionClasses(DefaultBeanContext.java:3326)
2023-02-27T19:23:42.277751377Z 	at io.micronaut.context.DefaultBeanContext.finalizeConfiguration(DefaultBeanContext.java:3684)
2023-02-27T19:23:42.277755955Z 	at io.micronaut.context.DefaultBeanContext.start(DefaultBeanContext.java:341)
2023-02-27T19:23:42.277758030Z 	at io.micronaut.context.DefaultApplicationContext.start(DefaultApplicationContext.java:194)
2023-02-27T19:23:42.277760216Z 	at io.micronaut.runtime.Micronaut.start(Micronaut.java:75)
2023-02-27T19:23:42.277763874Z 	at com.taltous.server.Application.main(Application.kt:24)
2023-02-27T19:23:42.277767909Z Caused by: io.micronaut.runtime.exceptions.ApplicationStartupException: Migration failed! Liquibase encountered an exception.
2023-02-27T19:23:42.277770040Z 	at io.micronaut.liquibase.AbstractLiquibaseMigration.migrate(AbstractLiquibaseMigration.java:146)
2023-02-27T19:23:42.277772155Z 	at io.micronaut.liquibase.AbstractLiquibaseMigration.forceRun(AbstractLiquibaseMigration.java:100)
2023-02-27T19:23:42.277777353Z 	at io.micronaut.liquibase.AbstractLiquibaseMigration.run(AbstractLiquibaseMigration.java:86)
2023-02-27T19:23:42.277787673Z 	at io.micronaut.liquibase.LiquibaseMigrationRunner.lambda$onCreated$1(LiquibaseMigrationRunner.java:64)
2023-02-27T19:23:42.277793870Z 	at [email protected]/java.util.Optional.ifPresent(Optional.java:178)
2023-02-27T19:23:42.277796183Z 	at io.micronaut.liquibase.LiquibaseMigrationRunner.onCreated(LiquibaseMigrationRunner.java:62)
2023-02-27T19:23:42.277798248Z 	at io.micronaut.liquibase.LiquibaseMigrationRunner.onCreated(LiquibaseMigrationRunner.java:39)
2023-02-27T19:23:42.277800578Z 	at io.micronaut.context.DefaultBeanContext.triggerBeanCreatedEventListener(DefaultBeanContext.java:2407)
2023-02-27T19:23:42.277803487Z 	at io.micronaut.context.DefaultBeanContext.postBeanCreated(DefaultBeanContext.java:2385)
2023-02-27T19:23:42.277808952Z 	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2309)
2023-02-27T19:23:42.277811874Z 	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2251)
2023-02-27T19:23:42.277813833Z 	at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3016)
2023-02-27T19:23:42.277815844Z 	at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
2023-02-27T19:23:42.277817886Z 	at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:2918)
2023-02-27T19:23:42.277823314Z 	at io.micronaut.context.DefaultBeanContext.loadContextScopeBean(DefaultBeanContext.java:2737)
2023-02-27T19:23:42.277825383Z 	at io.micronaut.context.DefaultBeanContext.initializeContext(DefaultBeanContext.java:1915)
2023-02-27T19:23:42.277827374Z 	... 7 common frames omitted
2023-02-27T19:23:42.277829357Z Caused by: liquibase.exception.ChangeLogParseException: liquibase.exception.SetupException: Cannot parse resource location: 'resource:/'
2023-02-27T19:23:42.277834808Z 	at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:25)
2023-02-27T19:23:42.277837181Z 	at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:406)
2023-02-27T19:23:42.277839237Z 	at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:391)
2023-02-27T19:23:42.277841126Z 	at liquibase.Liquibase$16.run(Liquibase.java:2020)
2023-02-27T19:23:42.277846505Z 	at liquibase.Scope.lambda$child$0(Scope.java:180)
2023-02-27T19:23:42.277848912Z 	at liquibase.Scope.child(Scope.java:189)
2023-02-27T19:23:42.277850812Z 	at liquibase.Scope.child(Scope.java:179)
2023-02-27T19:23:42.277852695Z 	at liquibase.Scope.child(Scope.java:158)
2023-02-27T19:23:42.277857613Z 	at liquibase.Liquibase.runInScope(Liquibase.java:2445)
2023-02-27T19:23:42.277860393Z 	at liquibase.Liquibase.listUnrunChangeSets(Liquibase.java:2016)
2023-02-27T19:23:42.277862307Z 	at io.micronaut.liquibase.AbstractLiquibaseMigration.isUpdateNeeded(AbstractLiquibaseMigration.java:325)
2023-02-27T19:23:42.277871460Z 	at io.micronaut.liquibase.AbstractLiquibaseMigration.performUpdateIfNeeded(AbstractLiquibaseMigration.java:183)
2023-02-27T19:23:42.277874467Z 	at io.micronaut.liquibase.AbstractLiquibaseMigration.migrate(AbstractLiquibaseMigration.java:140)
2023-02-27T19:23:42.277876472Z 	... 22 common frames omitted

Steps To Reproduce

  1. Configure a typical Micronaut application, using Liquibase:
implementation("io.micronaut.liquibase:micronaut-liquibase")

The notable part on application.yml:

liquibase:
  datasources:
    default:
      change-log: db/migration/change-log.xml

The change-log.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
         https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">

    <includeAll path="liquibase" relativeToChangelogFile="true"/>

</databaseChangeLog>

The migration files are stored using SQL scripts in the appropriate directory:

image

Build a native image for Docker and run the container. The application fail to start with the error mentioned above.

Note: The migrations start normally when running from Gradle, with no native image support.

Environment Information

  • Windows 11
  • Java:
openjdk 17.0.5 2022-10-18
OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08, mixed mode, sharing)

Example Application

No response

Version

3.8.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant