sofastack / sofa-boot

SOFABoot is a framework that enhances Spring Boot and fully compatible with it, provides readiness check, class isolation, etc.
https://www.sofastack.tech/sofa-boot/docs/Home
Apache License 2.0
4.92k stars 1.26k forks source link

使用SofaService注解发布非JVM服务异常(Can not found binding converter for binding type bolt) #142

Closed recollects closed 5 years ago

recollects commented 5 years ago

`@SofaService(bindings = @SofaServiceBinding(bindingType = "jvm")) @Service public class SampleServiceImpl implements SampleService {

@Override
public String message() {
    return "hello sofa";
}

} `

` if (JvmBinding.JVM_BINDING_TYPE.getType().equals( sofaReferenceAnnotation.binding().bindingType())) { reference.addBinding(new JvmBinding()); } else { BindingConverter bindingConverter = bindingConverterFactory .getBindingConverter(new BindingType(sofaReferenceAnnotation.binding() .bindingType())); if (bindingConverter == null) { throw new ServiceRuntimeException( "Can not found binding converter for binding type "

debug源码部分这个绑定转换器工厂好像没有向这个map里添加绑定转换器! 版本:sofa-boot 2.4.0 SofaRuntimeSpringContextInitializer.initialize这个方法并没有初始化bingdingConverterFactory,所以map里是空的。 看了版本:sofa-boot 2.3.1有初始的操作但是ServiceLoader.load(BindingConverter.class)没有找到关于bolt或者其它类的配置项,相当于bindingConverterFactory里的map转换器还是空的! 麻烦sofa团队大神门帮忙看一下,谢谢啦

leizhiyuan commented 5 years ago

升级到 sofa-boot 2.4.3 看看呢.

image

rpc 的工程里有个 sample.

recollects commented 5 years ago

感谢解答,我升到了2.4.3.这个例子也从找到了 image 发布服务还是同样的报错! 你运行那个例子是正常的嘛? 因为我查看源码没有找到com.alipay.sofa.runtime.spi.service.BindingConverter这转换器配置文件,在META-INF/services下的文件,所以才会“Can not found binding converter for binding type bolt”

leizhiyuan commented 5 years ago

你项目中是引入了 rpc 的 starter?

<dependency>
     <groupId>com.alipay.sofa</groupId>
     <artifactId>rpc-sofa-boot-starter</artifactId>
</dependency>

http://www.sofastack.tech/sofa-rpc/docs/Getting-Started-with-SOFA-Boot

recollects commented 5 years ago

嗯,这些都引了,发布jvm服务正常,发布其它bolt服务异常。最新源码也下下来了看了! com.alipay.sofa.runtime.spi.service.BindingConverter这转换器配置文件我这里没有找到,binging适配器配置文件是有的,可能是没有这个配置文件ServiceLoader.load加载不到实现吧,麻烦大神看下

leizhiyuan commented 5 years ago

@recollects 能否提交一下你的工程到你的公开仓库?这样方便排查,这个文件可以确认肯定是有的 image

recollects commented 5 years ago

我已经提交上去了,地址:https://github.com/recollects/sofaboot.git 我的意思是加载 image 应该有这种配置文件的。 运行AnnotationServerApplication这个文件,可以看到错误‘Can not found binding converter for binding type bolt’ 麻烦看看

leizhiyuan commented 5 years ago

@recollects 你只是加在了主 pom 的依赖管理里面,可以看一下 mvn 的依赖管理,要真正生效,要在子 pom 中引入.或者按照我们的官方文档来引入依赖.

image

image