diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/SchemaMigration.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/SchemaMigration.kt index a867ed43cf..aee1af663d 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/SchemaMigration.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/SchemaMigration.kt @@ -13,7 +13,6 @@ import net.corda.nodeapi.internal.MigrationHelpers.getMigrationResource import net.corda.core.schemas.MappedSchema import net.corda.core.utilities.contextLogger import net.corda.nodeapi.internal.cordapp.CordappLoader -import sun.security.x509.X500Name import java.io.ByteArrayInputStream import java.io.InputStream import java.nio.file.Path @@ -115,6 +114,7 @@ class SchemaMigration( } System.setProperty(NODE_X500_NAME, ourName.toString()) val customResourceAccessor = CustomResourceAccessor(dynamicInclude, changelogList, classLoader) + checkResourcesInClassPath(changelogList) // current version of Liquibase appears to be non-threadsafe // this is apparent when multiple in-process nodes are all running migrations simultaneously @@ -209,6 +209,7 @@ class SchemaMigration( if (preV4Baseline.isNotEmpty()) { val dynamicInclude = "master.changelog.json" // Virtual file name of the changelog that includes all schemas. + checkResourcesInClassPath(preV4Baseline) dataSource.connection.use { connection -> val customResourceAccessor = CustomResourceAccessor(dynamicInclude, preV4Baseline, classLoader) val liquibase = Liquibase(dynamicInclude, customResourceAccessor, getLiquibaseDatabase(JdbcConnection(connection))) @@ -217,6 +218,14 @@ class SchemaMigration( } return isExistingDBWithoutLiquibase || isFinanceAppWithLiquibaseNotMigrated } + + private fun checkResourcesInClassPath(resources: List) { + for (resource in resources) { + if (classLoader.getResource(resource) == null) { + throw DatabaseMigrationException("Could not find Liquibase database migration script $resource. Please ensure the jar file containing it is deployed in the cordapps directory.") + } + } + } } open class DatabaseMigrationException(message: String) : IllegalArgumentException(message) {