I am running Java code changeset in liquibase. But I am facing this issue where I am getting ClassNotFoundException.I did some searching around but could not find anything helpful. Alltough some research at this link was useful. I am using liquibase-core-2.0.1.
Below is my Changeset
<changeSet id="111" author="myname" >
<customChange class="com.example.CreateTableTask">
</customChange>
</changeSet>
Below is my java class
public class CreateTableTask implements CustomTaskChange
{
private static Logger log = Logger.getLogger(CreateTableTask.class.getName());
@Override
public void execute(Database database) throws CustomChangeException
{
System.out.print("testsomestring");
try
{
JdbcConnection databaseConnection = (JdbcConnection) database.getConnection();
log.info("testsomestring");
}
catch (Exception e)
{
throw new CustomChangeException(e);
}
}
@Override
public String getConfirmationMessage()
{
return null;
}
@Override
public void setUp() throws SetupException
{
}
@Override
public void setFileOpener(ResourceAccessor resourceAccessor)
{
}
@Override
public ValidationErrors validate(Database database)
{
return null;
}
}
Below is the exception I am getting
java.lang.ClassNotFoundException: com.example.CreateTableTask liquibase.exception.ChangeLogParseException: Invalid Migration File: java.lang.ClassNotFoundException: com.example.CreateTableTask at liquibase.parser.core.xml.XMLChangeLogSAXParser.parse(XMLChangeLogSAXParser.java:132) at liquibase.Liquibase.update(Liquibase.java:107) at liquibase.integration.commandline.Main.doMigration(Main.java:825) at liquibase.integration.commandline.Main.main(Main.java:134) Caused by: org.xml.sax.SAXException: java.lang.ClassNotFoundException: com.example.CreateTableTask liquibase.exception.CustomChangeException: java.lang.ClassNotFoundException: com.example.CreateTableTask at liquibase.parser.core.xml.XMLChangeLogSAXHandler.startElement(XMLChangeLogSAXHandler.java:478) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:749) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:379) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2786) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:648) at liquibase.parser.core.xml.XMLChangeLogSAXParser.parse(XMLChangeLogSAXParser.java:98)