kotlin - net.corda.nodeapi.internal.persistence.CouldNotCreateDataSourceException:无法创建数据源
问题描述
我正在尝试使用此处的示例开发 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 }
解决方案
推荐阅读
- objective-c - Cocoa osx:制作一个 NSViewController 并将它的视图用于主窗口内容视图是个好主意吗?
- kubernetes - Kubernetes ExternalName 服务添加标头
- ansible - ansible 在远程主机上运行剧本
- mysql - 如何使用格式获取这些字段之间的值?
- c# - 请求被中止:无法创建 SSL/TLS 安全通道,但可以从浏览器/POSTMAN 工作
- javascript - 使用按钮将数据添加到对象数组
- java - jsoup 从只有一个类的 div 中检索文本
- reactjs - “class”属性在 JSX 中工作:如何?
- ios - 如何让相机功能仅显示在一个标签栏项目中?
- python - “主进程退出”错误 Gunicorn systemd 文件