Closed iteaj closed 5 years ago
There was an unexpected error (type=Internal Server Error, status=500). org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: JVM Reference[interface co demo.zip m.iteaj.service.TestService#] cant not find the corresponding JVM service. Please check if there is a SOFA deployment publish the corresponding JVM service. If this exception occurred when the application starts up, please add Require-Module to SOFA deployment's MANIFEST.MF to indicate the startup dependency of SOFA modules.
先咨询一下,使用jvm服务时业务代码里面的服务注册以及引用是否需要在spring的同一个ApplicationContext者父子关联的ApplicationContext
先咨询一下,使用jvm服务时业务代码里面的服务注册以及引用是否需要在spring的同一个ApplicationContext者父子关联的ApplicationContext
抱歉,才看到你的消息。 jvm 服务不要求引用和发布方的spring 上下文关系。
@iteaj 如果有比较急的问题,也可以单独给我发邮件 qilong.zql@antfin.com
@QilongZhang 你好, 已经找到问题但不知道是否是正确的。 每个biz包启动的时候框架都会为他们创建一个SofaRuntimeManager, 并且把他注册到SofaFramework里面, 如下代码 ` @Bean @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public static SofaRuntimeContext sofaRuntimeContext(@Value("${"
"}") String appName, BindingConverterFactory bindingConverterFactory, BindingAdapterFactory bindingAdapterFactory) { ClientFactoryInternal clientFactoryInternal = new ClientFactoryImpl(); SofaRuntimeManager sofaRuntimeManager = new StandardSofaRuntimeManager(appName, SofaRuntimeAutoConfiguration.class.getClassLoader(), clientFactoryInternal); sofaRuntimeManager.getComponentManager().registerComponentClient( ReferenceClient.class, new ReferenceClientImpl(sofaRuntimeManager.getSofaRuntimeContext(), bindingConverterFactory, bindingAdapterFactory)); sofaRuntimeManager.getComponentManager().registerComponentClient( ServiceClient.class, new ServiceClientImpl(sofaRuntimeManager.getSofaRuntimeContext(), bindingConverterFactory, bindingAdapterFactory)); SofaFramework.registerSofaRuntimeManager(sofaRuntimeManager); return sofaRuntimeManager.getSofaRuntimeContext();
} 在获取服务引用的时候去获取对应注册的服务c:如下
public ServiceProxy findServiceProxy(ClassLoader clientClassloader, Contract contract) {
String interfaceType = contract.getInterfaceType().getCanonicalName();
String uniqueId = contract.getUniqueId();
for (SofaRuntimeManager sofaRuntimeManager : SofaFramework.getRuntimeSet()) {
if (sofaRuntimeManager.getAppClassLoader().equals(clientClassloader)) {
continue;
}
Biz biz = getBiz(sofaRuntimeManager);
if (biz != null && biz.getBizState() == BizState.ACTIVATED) {
ServiceComponent serviceComponent = findServiceComponent(uniqueId, interfaceType,
sofaRuntimeManager.getComponentManager());
if (serviceComponent != null) {
return new DynamicJvmServiceInvoker(clientClassloader,
sofaRuntimeManager.getAppClassLoader(), serviceComponent.getService()
.getTarget(), contract, biz.getIdentity());
}
}
}
return null;
}`
但由于runtime-sofa-boot-starter-plugin插件没有导出SofaFramework类, 所以每个biz应用再加载这个类的时候不会委托给插件加载, 而是每个biz包自己加载SofaFramework类, 从而导致类SofaFramework并不是全局的, 这样多个biz包注册的服务项目引用不到。
解决方法:再插件里面导出SofaFramework类
@iteaj 你的分析是正确的,SOFABoot 代码重构的时候这部分应该是没有测试,我们会尽快修复~
@QilongZhang 快修复吧,这个demo很重要!
@puzhi 好的,我今晚修复~ 多谢反馈
@QilongZhang 为什么依然无法运行!是我什么地方没做对吗?我的环境
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>runtime-sofa-boot-starter</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
@puzhi 上面有链接的修复PR https://github.com/alipay/sofa-boot/pull/267 ,因为还没有合并,你可以把分支代码拉取下来本地安装。更新本地 jarslink 代码,运行 biz-jvm-invocation-sample 即可。
Your question
再ark容器里面创建两个web的biz包, 其中一个发布服务, 一个引用服务, 然后再调用的时候提示 《cant not find the corresponding JVM service. Please check if there is a SOFA deployment publish the corresponding JVM service》
Your scenes
describe your use scenes (why need this feature)
Your advice
describe the advice or solution you'd like
Environment
java -version
):uname -a
):