+
Skip to content

On node startup, resumed flow does not have previously set Thread.contextClassLoader causing ClassNotFoundException #7681

Open
@adamturski

Description

@adamturski

One of our Cordapps 3rd party library loads classes dynamically using following code:

ClassLoader loader = Thread.currentThread().getContextClassLoader();
return loader != null ? loader.loadClass(fullName) : Class.forName(fullName);

https://github.com/JodaOrg/joda-convert/blob/d226248e25f0b16cd7f573389e9bddf1fb4f0b47/src/main/java/org/joda/convert/StringConvert.java#L883

Normally it does not cause any issue on running flow, maybe because of following line in FlowStateMachineImpl, but I'm not sure.

Thread.currentThread().contextClassLoader = serviceHub.cordappProvider.appClassLoader

Problem is that when flow is running and node is restarted, then on startup the flow is resumed and it fails with ClassNotFoundException for requested class from the cordapp - Thread.contextClassLoader does not have any of cordapp classes, only Corda classes.

Maybe when resuming the flow in such case we should set Thread.contextClassLoader as it was set originally in FlowStateMachineImpl.kt#L349 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载