Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
adamturski opened this issue Mar 1, 2024 · 0 comments

Comments

@adamturski
Copy link

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant