#StackBounty: #kotlin #liquibase #corda #discordapp net.corda.nodeapi.internal.persistence.CouldNotCreateDataSourceException: Could not…

Bounty: 50

I’m trying to develop a CorDapp using the example here. I’ve added two modules into my project, one for contracts and the other one for flows. I’ve added test cases for my contract and it works fine, but test cases for flow fail on setup stage. Here’s the code of my test class

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
 class SharedInformationFlowTests {
   private lateinit var network: MockNetwork
   private lateinit var a: StartedMockNode
   private val proposal = LedgerUpdateProposal.testProposal()

@BeforeAll
fun setup() {
    val params = MockNetworkParameters(cordappsForAllNodes = listOf(
            TestCordapp.findCordapp("com.something.contract")
    ))

    network = MockNetwork(params) //fails here
    a = network.createPartyNode()
    network.runNetwork()
}

@AfterAll
fun tearDown() {
    network.stopNodes()
}

And here are the error messages I get:

[WARN] 13:42:52,620 [main] spi.SqlExceptionHelper. - SQL Error: 0, SQLState: null {changeSet=migration/vault-schema.changelog-v9.xml::update-vault-states::R3.Corda, databaseChangeLog=master.changelog.json}
[ERROR] 13:42:52,620 [main] spi.SqlExceptionHelper. - Connection is closed {changeSet=migration/vault-schema.changelog-v9.xml::update-vault-states::R3.Corda, databaseChangeLog=master.changelog.json}


net.corda.nodeapi.internal.persistence.CouldNotCreateDataSourceException: Could not create the 
DataSource: Migration failed for change set migration/vault-schema.changelog-v9.xml::update-vault-states::R3.Corda:
 Reason: net.corda.nodeapi.internal.persistence.HibernateConfigException: Could not create Hibernate configuration: Unable to open JDBC Connection for DDL execution

I think there’s something wrong with the liquibase. I’ve tried adding changelog file to my resources/migration directory as advised here, but it doesn’t seem to have any effect. Please help.

UPDATE Added schema

/**
 * The family of com.sentinel.schemas for SharingInformationState.
 */
object SharingInformationSchema

/**
 * An SharingInformationState schema.
 */
object SharingInformationSchemaV1 : MappedSchema(
    schemaFamily = SharingInformationSchema.javaClass,
    version = 1,
    mappedTypes = listOf(PersistentSharingInformation::class.java)) {
override val migrationResource: String? = "sharing-information-schema-v1.changelog-master.xml"

@Entity
@Table(name = "persistent_sharing_information")
class PersistentSharingInformation(
        @Column(name = "owner_id")
        var dataOwnerId: Long,

        @Column(name = "buyer_id")
        var dataBuyerId: Long,

        @Column(name = "start_date")
        val startDate: String,

        @Column(name = "end_date")
        val endDate: String,

        @Column(name = "shared_fields")
        val sharedFieldsIds: String,

        @Column(name = "agreement_status")
        val agreementStatus: String,

        @Column(name = "contract_type")
        val contractType: String,

        @Column(name = "linear_id")
        var linearId: UUID
) : PersistentState() {

    // Default constructor required by hibernate.
    constructor() : this(0L,  0L,
            "", "", "[]", "", "", UUID.randomUUID())
}

}


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.