I'm struggling to understand the cause of the issue that I'm facing.
I have a module with Contracts and module with Validators. Some of the Validators are being used in Contracts' module. For example:
override fun verify(tx: LedgerTransaction){
validator.validate(tx.outputs)
}
I start my flow and during Contract verification, I see: ClassNotFoundException so the Class from Validators module cannot be found in the classloader. Obviously, CorDapp with Validators exists in the node.
While debugging Corda Framework, I can see that attachments will be uploaded into AttachmentStorageInternal
during the start-up, but only those jar which includes Contracts.
private fun loadContractsIntoAttachmentStore(): Map<SecureHash, URL> =
cordapps.filter { !it.contractClassNames.isEmpty() }.map {
it.jarPath.openStream().use { stream -> //some code}
Moreover, I can see that during a Verification stage, when ClassNotFoundException
or ClassNotDefFoundException
occurs, then Corda will try to load missing class, but it will try to find it only from Contract Attachments that were uploaded on the start-up of the Node.
fun AttachmentStorage.internalFindTrustedAttachmentForClass(className: String): Attachment? {
val allTrusted = queryAttachments(
AttachmentQueryCriteria.AttachmentsQueryCriteria().withUploader(Builder.`in`(TRUSTED_UPLOADERS)),
AttachmentSort(listOf(AttachmentSort.AttachmentSortColumn(AttachmentSort.AttachmentSortAttribute.VERSION, Sort.Direction.DESC))))
for (attId in allTrusted) {
- Can someone point me out, how Corda will load helper classes that
Contract's
verify()
method might need in my implementation? - Is it possible to use classes from other modules in Contacts' CorDapp?