Opendaylight Hello World RPC 抛出 "Unable to find a matching constructor" 错误

Opendaylight Hello World RPC throw "Unable to find a matching constructor" error

我是 Opendaylight 的新手,所以我尝试通过本教程在 Magnesium 上构建 Hello api。

https://docs.opendaylight.org/en/stable-magnesium/developer-guide/developing-apps-on-the-opendaylight-controller.html

我正在按照教程所说的一步步进行,但是在构建应用程序时遇到了错误

Unable to find a matching constructor on class org.opendaylight.hello.impl.HelloProvider for
arguments [org.apache.aries.blueprint.container.ReferenceRecipe$ServiceProxyWrapper@3dc7838f 
(class org.apache.aries.blueprint.container.ReferenceRecipe$ServiceProxyWrapper), 
org.apache.aries.blueprint.container.ReferenceRecipe$ServiceProxyWrapper@665cb91b (class             
org.apache.aries.blueprint.container.ReferenceRecipe$ServiceProxyWrapper)] when instanciating 
bean provider

我已经用谷歌搜索了一段时间并尝试了这个解决方案,但不幸的是这并没有解决我的问题。

最终impl/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml文件如下;

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
  xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
  odl:use-default-for-reference-types="true">

  <reference id="dataBroker"
    interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
    odl:type="default" />
  <reference id="rpcProviderService"
    interface="org.opendaylight.mdsal.binding.api.RpcProviderService"
    odl:type="default" />


  <bean id="provider"
    class="org.opendaylight.hello.impl.HelloProvider"
    init-method="init" destroy-method="close">
    <argument ref="dataBroker" />
    <argument ref="rpcProviderService" />
  </bean>

</blueprint>

杨档案:

module hello {
    yang-version 1;
    namespace "urn:opendaylight:params:xml:ns:yang:hello";
    prefix "hello";
    revision "2019-11-27" {
        description "Initial revision of hello model";
    }
    rpc hello-world {
        input {
            leaf name {
                type string;
            }
        }
        output {
            leaf greeting {
                type string;
            }
        }
    }
}

HelloProvider.java:

package org.opendaylight.hello.impl;

import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hello.rev191127.HelloService;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class HelloProvider {

    private static final Logger LOG = LoggerFactory.getLogger(HelloProvider.class);

    private final DataBroker dataBroker;
    private ObjectRegistration<HelloService> helloService;
    private RpcProviderService rpcProviderService;

    public HelloProvider(final DataBroker dataBroker, final RpcProviderService rpcProviderService) {
        this.dataBroker = dataBroker;
        this.rpcProviderService = rpcProviderService;
    }

    /**
    * Method called when the blueprint container is created.
    */
    public void init() {
        LOG.info("HelloProvider Session Initiated");
        helloService = rpcProviderService.registerRpcImplementation(HelloService.class, new HelloWorldImpl());
    }

    /**
    * Method called when the blueprint container is destroyed.
    */
    public void close() {
        LOG.info("HelloProvider Closed");
        if (helloService != null) {
            helloService.close();
        }
    }
}

那么问题是什么?

蓝图中 HelloProviderDataBroker 构造函数参数类型 XML (org.opendaylight.controller.md.sal.binding.api.DataBroker) 与代码不匹配 (org.opendaylight.mdsal.binding.api.DataBroker) .