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

Request for minimal example for integration with Spring Boot #698

Open
ghferrari opened this issue May 21, 2024 · 1 comment
Open

Request for minimal example for integration with Spring Boot #698

ghferrari opened this issue May 21, 2024 · 1 comment

Comments

@ghferrari
Copy link

I'm trying out Spring Boot for the first time and looking to create a minimal project which achieves the following:

  • uses Gradle+Kotlin as the build tool
  • allows liquibase to generate database changes using the JPA/Hibernate model entities I define within Spring Boot.

I appreciate this question cuts across Spring, liquibase, gradle and this plugin, but it wasn't obvious where else to ask for help with this and I think it is probably the liquibase-hibernate configuration that I ultimately need help with. And it would be a great service to newbies like myself if someone could provide a minimal working example. I've spent several days trying to achieve this with no success so far.

Thanks in advance if anyone can offer any advice.

At the moment, I get the following error when running the liquibase generateChangelog command from within Gradle:

Task :generateChangelog FAILED
liquibase-plugin: Running the 'main' activity...
May 21, 2024 12:06:53 PM liquibase.servicelocator
INFO: Cannot load service: liquibase.configuration.AutoloadedConfigurations: Provider com.datical.liquibase.ext.config.LiquibaseProConfiguration could not be instantiated
May 21, 2024 12:06:53 PM liquibase.servicelocator
INFO: Cannot load service: liquibase.configuration.AutoloadedConfigurations: Provider com.datical.liquibase.ext.config.NativeExecutorConfiguration could not be instantiated
May 21, 2024 12:06:53 PM liquibase.servicelocator
INFO: Cannot load service: liquibase.configuration.AutoloadedConfigurations: Provider com.datical.liquibase.ext.config.LiquibaseFlowConfiguration could not be instantiated
May 21, 2024 12:06:53 PM liquibase.servicelocator
INFO: Cannot load service: liquibase.configuration.AutoloadedConfigurations: Provider com.datical.liquibase.ext.config.ReportConfiguration could not be instantiated
May 21, 2024 12:06:53 PM liquibase.servicelocator
INFO: Cannot load service: liquibase.configuration.AutoloadedConfigurations: Provider com.datical.liquibase.ext.config.ExtendedLiquibaseCommandLineConfiguration could not be instantiated
May 21, 2024 12:06:53 PM liquibase.servicelocator
INFO: Cannot load service: liquibase.configuration.AutoloadedConfigurations: Provider com.datical.liquibase.ext.config.SqlplusConfiguration could not be instantiated
May 21, 2024 12:06:53 PM liquibase.servicelocator
INFO: Cannot load service: liquibase.logging.LogService: Provider com.datical.liquibase.ext.logging.structured.StructuredLogService could not be instantiated
May 21, 2024 12:06:53 PM liquibase.servicelocator
INFO: Cannot load service: liquibase.command.CommandStep: com.datical.liquibase.ext.command.RollbackOneChangesetSqlCommandStep Unable to get public no-arg constructor
Exception in thread "main" java.lang.NoClassDefFoundError: liquibase/command/CleanUpCommandStep
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:534)
	at java.base/java.lang.Class.forName(Class.java:513)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1217)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1228)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1273)
	at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309)
	at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1393)
	at liquibase.servicelocator.StandardServiceLocator.findInstances(StandardServiceLocator.java:22)
	at liquibase.command.CommandFactory.findAllInstances(CommandFactory.java:147)
	at liquibase.command.CommandFactory.getCommands(CommandFactory.java:69)
	at liquibase.integration.commandline.LiquibaseCommandLine.getCommands(LiquibaseCommandLine.java:978)
	at liquibase.integration.commandline.LiquibaseCommandLine.buildPicoCommandLine(LiquibaseCommandLine.java:202)
	at liquibase.integration.commandline.LiquibaseCommandLine.<init>(LiquibaseCommandLine.java:178)
	at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:82)
Caused by: java.lang.ClassNotFoundException: liquibase.command.CleanUpCommandStep
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
Caused by: java.lang.ClassNotFoundException: liquibase.command.CleanUpCommandStep

	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	... 33 more
@aDramaQueen
Copy link

aDramaQueen commented Sep 3, 2024

Hi, yes I struggled with this too at the beginning. There is a subtle information that is missing in the Documentation:

You have to compile your project before executing any Liquibase operation.

Liquibase is NOT looking at your source code, instead it is looking at your byte code. Which makes sense, because with Spring/Hibernate you heavily rely on code injection that you do not see at your source code, but is generated automatically for you.

You have mentioned that you're using Gradle. I do too. Therefore to make sure the project is alway "fresh", I added following line into my build.gradle:

tasks.named('diffChangelog') {
    dependsOn(compileJava)
}

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

2 participants