liquibase / liquibase-gradle-plugin

A Gradle plugin for Liquibase
Other
197 stars 57 forks source link

Cannot load service - Json/Yaml parsers could not be instantiated #84

Closed faocrates closed 3 years ago

faocrates commented 3 years ago

When running I get the two messages below, does anyone know how to get those two services loaded?

INFO [liquibase.servicelocator] Cannot load service: liquibase.parser.ChangeLogParser: Provider liquibase.parser.core.json.JsonChangeLogParser could not be instantiated INFO [liquibase.servicelocator] Cannot load service: liquibase.parser.ChangeLogParser: Provider liquibase.parser.core.yaml.YamlChangeLogParser could not be instantiated

stevesaliman commented 3 years ago

I'm afraid this doesn't give me much to go on. It looks like it is complaining about the parsers that are built into Liquibase, so they should be found if liquibase is declared as a liquibaseRuntime dependency.

What version of Liquibase, Gradle, and the gradle plugin are you using? Can you share the relevant parts of your build.gradle file?

faocrates commented 3 years ago

Hi Steve, please see below the relevant parts and versions,

Gradle 6.7.1

plugins { id 'java' id 'org.liquibase.gradle' version '2.0.4' }

liquibase { activities { main { ... } } }

dependencies { ... liquibaseRuntime 'org.liquibase:liquibase-core:4.2.2' liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:3.0.0' liquibaseRuntime group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1' liquibaseRuntime group: 'com.h2database', name: 'h2', version: '1.4.200' }

stevesaliman commented 3 years ago

When I change up my sample project, I can get a warning, but my warning is a little different:

[2021-03-06 12:54:42] INFO [liquibase.servicelocator] Cannot load service: liquibase.parser.ChangeLogParser: liquibase.parser.core.json.JsonChangeLogParser Unable to get public no-arg constructor
[2021-03-06 12:54:42] INFO [liquibase.servicelocator] Cannot load service: liquibase.parser.ChangeLogParser: liquibase.parser.core.yaml.YamlChangeLogParser Unable to get public no-arg constructor

In my case, having liquibaseRuntime "org.springframework.boot:spring-boot-starter-data-jpa" in my dependencies made the message go away. I was using that dependency because I was testing Liquibase commands with the liquibase-hibernate extension in a spring boot project, but I don't think that dependency is what makes the message go away. I think the JSON and YAML parsers need certain things on the classpath for the parsers to be loaded properly. In my case, I'm not using JSON or YAML changelogs, so this doesn't cause any issues running Liquibase.

What parser are you trying to use, and do these errors prevent you from running?

faocrates commented 3 years ago

Thank you, I use XML rather than Json or Yaml so these warnings do not affect me, I was just wondering if there were any ideas on what would be the dependencies that I could include to make the "cannot load service" messages go away.

stevesaliman commented 3 years ago

The only idea I have is to look at what spring-boot-starter-data-jpa brings in, and see if any of them have something to do with JSON or YAML.

If it was my project, however, I would leave the project as is and ignore the message. That seems better to me than including dependencies the project doesn't ultimately need.