net.corda.nodeapi.internal.persistence.CouldNotCreateDataSourceException: не удалось создать источник данных - PullRequest
2 голосов
/ 17 июня 2020

Я пытаюсь разработать CorDapp, используя пример здесь . Я добавил в свой проект два модуля: один для контрактов, а другой - для потоков. Я добавил тестовые примеры для своего контракта, и он работает нормально, но тестовые примеры для потока не работают на этапе настройки. Вот код моего тестового класса

@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()
}

И вот сообщения об ошибках, которые я получаю:

[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

Я думаю, что с Liquibase что-то не так. Я пробовал добавить файл журнала изменений в свой каталог resources/migration, как , рекомендованный здесь , но, похоже, это не имеет никакого эффекта. Пожалуйста, помогите.

ОБНОВЛЕНИЕ Добавлена ​​схема

/**
 * 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())
}

}

 @BelongsToContract(com.package.contract.SharingInformationContract::class)
 class SharingInformationState(val ourParty: Party,
                          val proposal: LedgerUpdateProposal,
                          override val linearId: UniqueIdentifier = UniqueIdentifier()) : LinearState, QueryableState {

override val participants: List<AbstractParty> = listOf(ourParty)

override fun generateMappedObject(schema: MappedSchema): PersistentState {
    return when (schema) {
        SharingInformationSchemaV1 -> SharingInformationSchemaV1.PersistentSharingInformation(
                proposal.ownerId,
                proposal.buyerId,
                proposal.startDate,
                proposal.endDate,
                proposal.sharedFieldsIds.toString(),
                proposal.agreementStatus.name,
                proposal.contractType.name,
                linearId.id
        )
        else -> throw IllegalArgumentException("Unrecognised schema $schema")
    }
}

override fun supportedSchemas(): Iterable<MappedSchema> = listOf(SharingInformationSchemaV1)

}

  @CordaSerializable
  enum class AgreementStatus { APPROVED, REJECTED }
  @CordaSerializable
  enum class ContractType { CORPORATE, CONSUMER, MARKETING, BINDING }
...