I’m using node-liquibase to connect to mysql. The general migration commands are working fine but I also need to implement a customTask so am trying to get a simple example working. I’m using Ubuntu 20.04 and liquibase 4.4.0
I’ve done the following:
- Copied one of the java custom task examples, compiled it to .java, then .jar using javac with liquibase.jar as a dependency using:
javac -cp liquibase.jar ExampleCustomTaskChange.java && jar cvf ExampleCustomTaskChange.jar ExampleCustomTaskChange.java
- Place ExampleCustomTaskChange.jar file in the root of the project.
- Updated the class paths value in the node code that generates the command for liquibase to run.
- Referenced the class name in the xml changeset and use what I believe is the correct xml structure.
This produces the following command:
[NODE-LIQUIBASE] Running /development/liquibase-poc/node_modules/liquibase/dist/liquibase/liquibase --changeLogFile=“./migrations/changelog.xml” --url=“jdbc:mariadb://localhost:3306/test?allowMultiQueries=TRUE” --username=“root” --password=“root” --classpath=“./ExampleCustomTaskChange.jar:./node_modules/liquibase/dist/drivers/mariadb-java-client-2.5.3.jar” --logLevel=“info” update …
[NODE-LIQUIBASE]
My example java class begins with:
package com.example;
import liquibase.change.custom.*;
import liquibase.Scope;
import liquibase.database.Database;
import liquibase.exception.CustomChangeException;
import liquibase.exception.RollbackImpossibleException;
import liquibase.exception.SetupException;
import liquibase.exception.ValidationErrors;
import liquibase.resource.ResourceAccessor;public class ExampleCustomTaskChange implements CustomTaskChange, CustomTaskRollback
The custom changeset xml is here in this gist:
However, I keep getting this error when trying to execute the custom changeset:
[2022-02-03 14:55:20]
SEVERE [liquibase.integration] java.lang.ClassNotFoundException: com.example.ExampleCustomTaskChange
liquibase.exception.CommandExecutionException: liquibase.exception.LiquibaseException: Unexpected error running Liquibase: liquibase.parser.core.ParsedNodeException: liquibase.exception.CustomChangeException: java.lang.ClassNotFoundException: com.example.ExampleCustomTaskChange
at liquibase.command.CommandScope.execute(CommandScope.java:153)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:45)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:15)
at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
Can anyone spot the problem?