[apache/dubbo]spring boot dubbo 3.1.1 启动输出错误信息

2024-06-24 483 views
6

triple 协议provider 和 consumer 启动报错,

@DubboService()
public class GrpcGreeterImpl extends DubboGreeterTriple.GreeterImplBase {

    @Override
    public HelloReply sayHello(HelloRequest request) {
        System.out.println("Executing thread is " + Thread.currentThread().getName());
        return HelloReply.newBuilder().setMessage("Hello " + request.getName()).build();
    }
}

application.yml

dubbo:
  application:
    name: dubbo-springboot-demo-provider
  protocol:
    name: tri
  registry:
    id: zk-registry
    address: zookeeper://127.0.0.1:2181
  config-center:
    address: zookeeper://127.0.0.1:2181
  metadata-report:
    address: zookeeper://127.0.0.1:2181
server:
  port: 8181
[23/10/22 22:16:20:462 CST] main  INFO metadata.MappingCacheManager:  [DUBBO] Successfully loaded mapping cache from file .mapping.dubbo-springboot-demo-provider, entries 0, dubbo version: 3.1.1, current host: 192.168.3.82
[23/10/22 22:16:20:469 CST] main  INFO migration.MigrationRuleListener:  [DUBBO] Listening for migration rules on dataId dubbo-springboot-demo-provider.migration, group DUBBO_SERVICEDISCOVERY_MIGRATION, dubbo version: 3.1.1, current host: 192.168.3.82
[23/10/22 22:16:20:471 CST] main  INFO config.ServiceConfig:  [DUBBO] Register dubbo service io.grpc.examples.helloworld.Greeter url tri://192.168.3.82:50051/io.grpc.examples.helloworld.Greeter?anyhost=true&application=dubbo-springboot-demo-provider&background=false&bind.ip=192.168.3.82&bind.port=50051&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=io.grpc.examples.helloworld.Greeter&ipv6=240e:390:e7a:94e1:7459:943:8f16:2&ispuserver=true&methods=sayHello,sayHelloAsync&pid=7789&proxy=nativestub&qos.enable=false&release=3.1.1&service-name-mapping=true&side=provider&timestamp=1666534580196 to registry 127.0.0.1:2181, dubbo version: 3.1.1, current host: 192.168.3.82
[23/10/22 22:16:20:471 CST] main  INFO protocol.QosProtocolWrapper:  [DUBBO] qos won't be started because it is disabled. Please check dubbo.application.qos.enable is configured either in system property, dubbo.properties or XML/spring-boot configuration., dubbo version: 3.1.1, current host: 192.168.3.82
[23/10/22 22:16:20:474 CST] main  INFO zookeeper.ZookeeperRegistry:  [DUBBO] Loaded registry cache file /Users/melin/.dubbo/dubbo-registry-dubbo-springboot-demo-provider-127.0.0.1-2181.cache, dubbo version: 3.1.1, current host: 192.168.3.82
[23/10/22 22:16:20:475 CST] main  INFO zookeeper.ZookeeperTransporter:  [DUBBO] find valid zookeeper client from the cache for address: zookeeper://127.0.0.1:2181/org.apache.dubbo.registry.RegistryService?REGISTRY_CLUSTER=zk-registry&application=dubbo-springboot-demo-provider&dubbo=2.0.2&interface=org.apache.dubbo.registry.RegistryService&pid=7789&proxy=nativestub&qos.enable=false&release=3.1.1, dubbo version: 3.1.1, current host: 192.168.3.82
[23/10/22 22:16:20:476 CST] main  INFO zookeeper.ZookeeperRegistry:  [DUBBO] Register: tri://192.168.3.82:50051/io.grpc.examples.helloworld.Greeter?anyhost=true&application=dubbo-springboot-demo-provider&background=false&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=io.grpc.examples.helloworld.Greeter&ipv6=240e:390:e7a:94e1:7459:943:8f16:2&ispuserver=true&methods=sayHello,sayHelloAsync&pid=7789&proxy=nativestub&release=3.1.1&service-name-mapping=true&side=provider&timestamp=1666534580196, dubbo version: 3.1.1, current host: 192.168.3.82
[23/10/22 22:16:20:488 CST] main  INFO zookeeper.ZookeeperRegistry:  [DUBBO] Subscribe: provider://192.168.3.82:50051/io.grpc.examples.helloworld.Greeter?anyhost=true&application=dubbo-springboot-demo-provider&background=false&bind.ip=192.168.3.82&bind.port=50051&category=configurators&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=io.grpc.examples.helloworld.Greeter&ipv6=240e:390:e7a:94e1:7459:943:8f16:2&ispuserver=true&methods=sayHello,sayHelloAsync&pid=7789&proxy=nativestub&qos.enable=false&release=3.1.1&service-name-mapping=true&side=provider&timestamp=1666534580196, dubbo version: 3.1.1, current host: 192.168.3.82
[23/10/22 22:16:20:519 CST] main  INFO zookeeper.ZookeeperRegistry:  [DUBBO] Notify urls for subscribe url provider://192.168.3.82:50051/io.grpc.examples.helloworld.Greeter?anyhost=true&application=dubbo-springboot-demo-provider&background=false&bind.ip=192.168.3.82&bind.port=50051&category=configurators&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=io.grpc.examples.helloworld.Greeter&ipv6=240e:390:e7a:94e1:7459:943:8f16:2&ispuserver=true&methods=sayHello,sayHelloAsync&pid=7789&proxy=nativestub&qos.enable=false&release=3.1.1&service-name-mapping=true&side=provider&timestamp=1666534580196, url size: 1, dubbo version: 3.1.1, current host: 192.168.3.82
[23/10/22 22:16:20:573 CST] DubboSaveMetadataReport-thread-1  INFO zookeeper.ZookeeperMetadataReport:  [DUBBO] store provider metadata. Identifier : org.apache.dubbo.metadata.report.identifier.MetadataIdentifier@3b021fc2; definition: FullServiceDefinition{parameters=org.apache.dubbo.common.url.component.URLParam$URLParamMap@8993b4fe} ServiceDefinition [canonicalName=io.grpc.examples.helloworld.Greeter, codeSource=file:/Users/melin/Documents/codes/examples/spring-dubbo-grpc-rest/interface/target/classes/, methods=[MethodDefinition [name=sayHelloAsync, parameterTypes=[io.grpc.examples.helloworld.HelloRequest], returnType=java.util.concurrent.CompletableFuture], MethodDefinition [name=sayHello, parameterTypes=[io.grpc.examples.helloworld.HelloRequest], returnType=io.grpc.examples.helloworld.HelloReply], MethodDefinition [name=sayHello, parameterTypes=[io.grpc.examples.helloworld.HelloRequest, org.apache.dubbo.common.stream.StreamObserver], returnType=void]]], dubbo version: 3.1.1, current host: 192.168.3.82
[23/10/22 22:16:20:586 CST] main  INFO config.ServiceConfig:  [DUBBO] Successfully registered interface application mapping for service io.grpc.examples.helloworld.Greeter, dubbo version: 3.1.1, current host: 192.168.3.82
[23/10/22 22:16:20:589 CST] main  INFO deploy.DefaultModuleDeployer:  [DUBBO] Dubbo Module[1.1.0] is starting., dubbo version: 3.1.1, current host: 192.168.3.82
[23/10/22 22:16:20:590 CST] main  INFO deploy.DefaultModuleDeployer:  [DUBBO] Dubbo Module[1.1.0] has started., dubbo version: 3.1.1, current host: 192.168.3.82
[23/10/22 22:16:20:590 CST] main  INFO deploy.DefaultModuleDeployer:  [DUBBO] Dubbo Module[1.1.1] has started., dubbo version: 3.1.1, current host: 192.168.3.82
[23/10/22 22:16:20:592 CST] main  INFO metadata.ConfigurableMetadataServiceExporter:  [DUBBO] Metadata Service Port hasn't been set will use default protocol defined in protocols., dubbo version: 3.1.1, current host: 192.168.3.82
[23/10/22 22:16:20:598 CST] main ERROR metadata.ConfigurableMetadataServiceExporter:  [DUBBO] Failed to find any valid protocol, will use random port to export metadata service., dubbo version: 3.1.1, current host: 192.168.3.82, error code: 5-16. This may be caused by invalid specified dubbo  protocol, go to https://dubbo.apache.org/faq/5/16 to find instructions. 
java.util.NoSuchElementException: No value present
    at java.util.Optional.get(Optional.java:135)
    at org.apache.dubbo.config.metadata.ConfigurableMetadataServiceExporter.getProtocolConfig(ConfigurableMetadataServiceExporter.java:104)
    at org.apache.dubbo.config.metadata.ConfigurableMetadataServiceExporter.generateMetadataProtocol(ConfigurableMetadataServiceExporter.java:136)
    at org.apache.dubbo.config.metadata.ConfigurableMetadataServiceExporter.buildServiceConfig(ConfigurableMetadataServiceExporter.java:194)
    at org.apache.dubbo.config.metadata.ConfigurableMetadataServiceExporter.export(ConfigurableMetadataServiceExporter.java:71)
    at org.apache.dubbo.config.metadata.ExporterDeployListener.onModuleStarted(ExporterDeployListener.java:71)
    at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.exportMetadataService(DefaultApplicationDeployer.java:924)
    at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.prepareApplicationInstance(DefaultApplicationDeployer.java:615)
    at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.checkState(DefaultApplicationDeployer.java:825)
    at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.notifyModuleChanged(DefaultApplicationDeployer.java:813)
    at org.apache.dubbo.config.deploy.DefaultModuleDeployer.onModuleStarted(DefaultModuleDeployer.java:262)
    at org.apache.dubbo.config.deploy.DefaultModuleDeployer.startSync(DefaultModuleDeployer.java:169)
    at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:137)
    at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onContextRefreshedEvent(DubboDeployApplicationListener.java:112)
    at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:101)
    at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:46)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378)
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
    at com.example.ProviderApplication.main(ProviderApplication.java:14)
[23/10/22 22:16:20:603 CST] main  INFO metadata.ConfigurableMetadataServiceExporter:  [DUBBO] Using dubbo protocol to export metadata service on port -1, dubbo version: 3.1.1, current host: 192.168.3.82

回答

4

pom 贴一下

5

Maybe we should enhance this error message

1

修改 spring boot starter版本和 dubbo 版本一致试试

3

dubbo 依赖的spring boot 版本太低了,升级一下吧。 [image: image.png]

7

这个问题是由 我们指定了 protocol为 非 dubbo 协议

  application:
    name: dubbo-springboot-demo-provider
   #metadata-service-protocol: tri 指定metadata协议
  protocol:
    name: tri
  registry:
    id: zk-registry
    address: zookeeper://127.0.0.1:2181
  config-center:
    address: zookeeper://127.0.0.1:2181
  metadata-report:
    address: zookeeper://127.0.0.1:2181
server:
  port: 8181

且没有全局指定 metadata-service-protocol 配置, metadata 会默认使用 dubbo协议 image 在后续获取 protocol 配置中 ,并没有找到dubbo类型的协议 image 即调用 optional.get 会抛出 image

2

这里没指定 metadata 协议 port 的时候 是使用用户指定的应用协议呢? 还是保持现在的 默认使用dubbo 但是 优化下 错误 提示

5

谢谢,已解决

1

这里最好将默认值改成从用户环境中获取已经配置的额 protocol,都没配置再使用 dubbo