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

Error java.lang.LinkageError occurred when use sofa-boot(v3.2.0) and sofa-ark(v1.0.0) together #478

Closed
ggndnn opened this issue Sep 13, 2019 · 1 comment · Fixed by #490
Labels
question Further information is requested
Milestone

Comments

@ggndnn
Copy link

ggndnn commented Sep 13, 2019

Based on sofa-boot v3.2.0 and sofa-ark 1.0.0, when I started application, I got a error:

Caused by: java.lang.LinkageError: loader constraint violation: when resolving interface method "com.alipay.sofa.runtime.spi.component.SofaRuntimeManager.registerShutdownAware(Lcom/alipay/sofa/runtime/spi/spring/RuntimeShutdownAware;)V" the class loader (instance of com/alipay/sofa/ark/container/service/classloader/BizClassLoader) of the current class, com/alipay/sofa/runtime/spring/RuntimeShutdownAwarePostProcessor, and the class loader (instance of com/alipay/sofa/ark/container/service/classloader/PluginClassLoader) for the method's defining class, com/alipay/sofa/runtime/spi/component/SofaRuntimeManager, have different Class objects for the type com/alipay/sofa/runtime/spi/spring/RuntimeShutdownAware used in the signature

After analysis, I found it's caused by that runtime-sofa-boot-plugin did not export com.alipay.sofa.runtime.spi.spring.RuntimeShutdownAware. Because RuntimeShutdownAwarePostProcessor was loaded by bizClassLoader, SofaRuntimeManager was loaded by pluginClassLoader, they both imported RuntimeShutdownAware, so two RuntimeShutdownAware classes ware loaded separately by bizClassLoader and pluginClassLoader, when RuntimeShutdownAwarePostProcessor tried to call SofaRuntimeManager's register method with a RuntimeShutdownAware instance, this error occurred.

Sofa-boot v3.1.5 did not have such issue, because RuntimeShutdownAwarePostProcessor was not added then (replacement of ApplicationShutdownCallbackPostProcessor?), and no other classes used RuntimeShutdownAware.

By the way, the class comment on RuntimeShutdownAwarePostProcessor is since 2.5.0, it's a little misleading, should it be since 3.2.0?

I think no harm done to export com.alipay.sofa.runtime.spi.spring.RuntimeShutdownAware by runtime-sofa-boot-plugin, that prevent bizClassLoader from loading this class. If you agree what I analyzed, I will submit a PR to fix this.

@glmapper
Copy link
Contributor

that is, you can provide PR to resolve this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
3 participants