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.
Based on sofa-boot v3.2.0 and sofa-ark 1.0.0, when I started application, I got a error:
After analysis, I found it's caused by that runtime-sofa-boot-plugin did not export
com.alipay.sofa.runtime.spi.spring.RuntimeShutdownAware
. BecauseRuntimeShutdownAwarePostProcessor
was loaded by bizClassLoader,SofaRuntimeManager
was loaded by pluginClassLoader, they both importedRuntimeShutdownAware
, so two RuntimeShutdownAware classes ware loaded separately by bizClassLoader and pluginClassLoader, whenRuntimeShutdownAwarePostProcessor
tried to callSofaRuntimeManager
'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 ofApplicationShutdownCallbackPostProcessor
?), and no other classes usedRuntimeShutdownAware
.By the way, the class comment on
RuntimeShutdownAwarePostProcessor
issince 2.5.0
, it's a little misleading, should it besince 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.