Reputation: 6334
I am attempting to implement a java triggered liquibase database update.
I have the following code:
java.sql.Connection connection = openConnection(eventContext);
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
String changelog = UpgradePanDatabase.class.getResource("/liquibase/db.changelog.xml").getPath();
Liquibase liquibase = new liquibase.Liquibase(changelog, new ClassLoaderResourceAccessor(), database);
liquibase.update(new Contexts(), new LabelExpression());
connection.close();
but I receive the following ChangeLogParseException:
/Users/ntregillus/myApp/.mule/apps/myApp/classes/liquibase/db.changelog.xml does not exist
But I know the file exists, I can copy the path, and open it directly from the terminal, and also find it within the File Explorer. Why is Liquibase not able to find this file?
Upvotes: 4
Views: 10730
Reputation: 539
UpgradePanDatabase.class.getResource("/liquibase/db.changelog.xml")
It will Search it wrt to "UpgradePanDatabase".class
Check if Absolute_path_of_FolderContaing_UpgradePanDatabase.class + /liquibase/db.changelog.xml> is same as in your IDE.
But in your case, it should be Wrt to "classes" Folder Try to debug -using SOP- what does "String changelog" say. That might help.
Upvotes: 0
Reputation: 9016
The most likely cause is that the changelog is not being packaged as a resource in the jar file. Check the structure of the packaged jar rather than your local developer working copy.
Upvotes: 8