How to import other opendaylight projects in my own odl distro

雨燕双飞 提交于 2019-12-11 16:18:43

问题


I'm trying to create my own application for Opendaylight, so for my application i will need some functions from the OpenFlowPlugin API.

After create the directories tree using the mvn generate:archtype, i've executed the mvn clean install and it worked well, but when i tried to add the new dependency of openflowplugin on the "features/" directory (both "features/pom.xml" and "features/src/main/features/features.xml") and re-execute the mvn clean install i got this error:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.opendaylight.odlparent.featuretest.SingleFeatureTest
Tests run: 5, Failures: 0, Errors: 5, Skipped: 0, Time elapsed: 97.286 sec <<< FAILURE! - in org.opendaylight.odlparent.featuretest.SingleFeatureTest
installFeature(org.opendaylight.odlparent.featuretest.SingleFeatureTest)[repoUrl: file:/home/kevin/agent/features/target/classes/features.xml, Feature: odl-agent-api 0.1.0-SNAPSHOT]  Time elapsed: 22.449 sec  <<< ERROR!
java.lang.IllegalArgumentException: Unrecognized root element: {http://karaf.apache.org/xmlns/features/v1.4.0}features
    at org.apache.karaf.features.internal.FeatureValidationUtil.validate(FeatureValidationUtil.java:83)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.validateRepository(FeaturesServiceImpl.java:174)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.internalAddRepository(FeaturesServiceImpl.java:245)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.getFeatures(FeaturesServiceImpl.java:930)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.getFeatures(FeaturesServiceImpl.java:853)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeature(FeaturesServiceImpl.java:383)
    at Proxy803580f9_299a_4e75_9327_ceb8193fd94e.installFeature(Unknown Source)
    at org.opendaylight.odlparent.featuretest.SingleFeatureTest.installFeature(SingleFeatureTest.java:340)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
    at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.lang.Thread.run(Thread.java:748)

installFeature(org.opendaylight.odlparent.featuretest.SingleFeatureTest)[repoUrl: file:/home/kevin/agent/features/target/classes/features.xml, Feature: odl-agent 0.1.0-SNAPSHOT]  Time elapsed: 18.787 sec  <<< ERROR!
java.lang.IllegalArgumentException: Unrecognized root element: {http://karaf.apache.org/xmlns/features/v1.4.0}features
    at org.apache.karaf.features.internal.FeatureValidationUtil.validate(FeatureValidationUtil.java:83)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.validateRepository(FeaturesServiceImpl.java:174)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.internalAddRepository(FeaturesServiceImpl.java:245)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.getFeatures(FeaturesServiceImpl.java:930)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.getFeatures(FeaturesServiceImpl.java:853)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeature(FeaturesServiceImpl.java:383)
    at Proxy93dd34dc_8bf7_4c49_b88e_434a37299c0c.installFeature(Unknown Source)
    at org.opendaylight.odlparent.featuretest.SingleFeatureTest.installFeature(SingleFeatureTest.java:340)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
    at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.lang.Thread.run(Thread.java:748)

installFeature(org.opendaylight.odlparent.featuretest.SingleFeatureTest)[repoUrl: file:/home/kevin/agent/features/target/classes/features.xml, Feature: odl-agent-rest 0.1.0-SNAPSHOT]  Time elapsed: 18.004 sec  <<< ERROR!
java.lang.IllegalArgumentException: Unrecognized root element: {http://karaf.apache.org/xmlns/features/v1.4.0}features
    at org.apache.karaf.features.internal.FeatureValidationUtil.validate(FeatureValidationUtil.java:83)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.validateRepository(FeaturesServiceImpl.java:174)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.internalAddRepository(FeaturesServiceImpl.java:245)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.getFeatures(FeaturesServiceImpl.java:930)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.getFeatures(FeaturesServiceImpl.java:853)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeature(FeaturesServiceImpl.java:383)
    at Proxycb898a77_a151_4429_8e2d_c78b7f977d25.installFeature(Unknown Source)
    at org.opendaylight.odlparent.featuretest.SingleFeatureTest.installFeature(SingleFeatureTest.java:340)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
    at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.lang.Thread.run(Thread.java:748)

installFeature(org.opendaylight.odlparent.featuretest.SingleFeatureTest)[repoUrl: file:/home/kevin/agent/features/target/classes/features.xml, Feature: odl-agent-ui 0.1.0-SNAPSHOT]  Time elapsed: 18.952 sec  <<< ERROR!
java.lang.IllegalArgumentException: Unrecognized root element: {http://karaf.apache.org/xmlns/features/v1.4.0}features
    at org.apache.karaf.features.internal.FeatureValidationUtil.validate(FeatureValidationUtil.java:83)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.validateRepository(FeaturesServiceImpl.java:174)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.internalAddRepository(FeaturesServiceImpl.java:245)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.getFeatures(FeaturesServiceImpl.java:930)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.getFeatures(FeaturesServiceImpl.java:853)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeature(FeaturesServiceImpl.java:383)
    at Proxyb9a3a1fb_f848_47c0_adb7_b80bd459aaa5.installFeature(Unknown Source)
    at org.opendaylight.odlparent.featuretest.SingleFeatureTest.installFeature(SingleFeatureTest.java:340)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
    at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.lang.Thread.run(Thread.java:748)

installFeature(org.opendaylight.odlparent.featuretest.SingleFeatureTest)[repoUrl: file:/home/kevin/agent/features/target/classes/features.xml, Feature: odl-agent-cli 0.1.0-SNAPSHOT]  Time elapsed: 18.844 sec  <<< ERROR!
java.lang.IllegalArgumentException: Unrecognized root element: {http://karaf.apache.org/xmlns/features/v1.4.0}features
    at org.apache.karaf.features.internal.FeatureValidationUtil.validate(FeatureValidationUtil.java:83)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.validateRepository(FeaturesServiceImpl.java:174)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.internalAddRepository(FeaturesServiceImpl.java:245)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.getFeatures(FeaturesServiceImpl.java:930)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.getFeatures(FeaturesServiceImpl.java:853)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeature(FeaturesServiceImpl.java:383)
    at Proxy5ebdeace_2897_4ea2_970b_0d94758d35d7.installFeature(Unknown Source)
    at org.opendaylight.odlparent.featuretest.SingleFeatureTest.installFeature(SingleFeatureTest.java:340)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
    at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.lang.Thread.run(Thread.java:748)


Results :

Tests in error: 
  Unrecognized root element: {http://karaf.apache.org/xmlns/features/v1.4.0}features
  Unrecognized root element: {http://karaf.apache.org/xmlns/features/v1.4.0}features
  Unrecognized root element: {http://karaf.apache.org/xmlns/features/v1.4.0}features
  Unrecognized root element: {http://karaf.apache.org/xmlns/features/v1.4.0}features
  Unrecognized root element: {http://karaf.apache.org/xmlns/features/v1.4.0}features

Tests run: 5, Failures: 0, Errors: 5, Skipped: 0

Here are the both pom.xml and the features.xml that i've edited:

POM.XML:

<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright © 2017 Yoyodyne, Inc. and others. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.opendaylight.odlparent</groupId>
    <artifactId>features-parent</artifactId>
    <version>1.8.3-SNAPSHOT</version>
    <relativePath/>
  </parent>

  <groupId>org.opendaylight.agent</groupId>
  <artifactId>agent-features</artifactId>
  <version>0.1.0-SNAPSHOT</version>
  <!-- <name> formatting is used by autorelease to parse and notify projects on
       build failure. Please do not modify this unless you have a good reason. -->
  <name>ODL :: org.opendaylight.agent :: ${project.artifactId}</name>

  <properties>
    <mdsal.model.version>0.10.3-SNAPSHOT</mdsal.model.version>
    <mdsal.version>1.5.3-SNAPSHOT</mdsal.version>
    <restconf.version>1.5.3-SNAPSHOT</restconf.version>
    <yangtools.version>1.1.3-SNAPSHOT</yangtools.version>
    <dluxapps.version>0.5.3-SNAPSHOT</dluxapps.version>
    <openflowplugin.version>0.6.0-SNAPSHOT</openflowplugin.version>
    <configfile.directory>etc/opendaylight/karaf</configfile.directory>
  </properties>

  <dependencyManagement>
    <dependencies>
      <!-- project specific dependencies -->
      <dependency>
        <groupId>org.opendaylight.controller</groupId>
        <artifactId>mdsal-artifacts</artifactId>
        <version>${mdsal.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.opendaylight.netconf</groupId>
        <artifactId>restconf-artifacts</artifactId>
        <version>${restconf.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.opendaylight.yangtools</groupId>
        <artifactId>yangtools-artifacts</artifactId>
        <version>${yangtools.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
    <groupId>org.opendaylight.openflowplugin</groupId>
    <artifactId>openflowplugin-artifacts</artifactId>
    <version>${openflowplugin.version}</version>
    <type>pom</type>
    <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.opendaylight.yangtools</groupId>
      <artifactId>features-yangtools</artifactId>
      <classifier>features</classifier>
      <type>xml</type>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.opendaylight.mdsal.model</groupId>
      <artifactId>features-mdsal-model</artifactId>
      <version>${mdsal.model.version}</version>
      <classifier>features</classifier>
      <type>xml</type>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.opendaylight.controller</groupId>
      <artifactId>features-mdsal</artifactId>
      <classifier>features</classifier>
      <type>xml</type>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.opendaylight.netconf</groupId>
      <artifactId>features-restconf</artifactId>
      <classifier>features</classifier>
      <type>xml</type>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.opendaylight.dluxapps</groupId>
      <artifactId>features-dluxapps</artifactId>
      <classifier>features</classifier>
      <version>${dluxapps.version}</version>
      <type>xml</type>
      <scope>runtime</scope>
    </dependency>
    <dependency>
    <groupId>org.opendaylight.openflowplugin</groupId>
    <artifactId>features-openflowplugin</artifactId>
    <classifier>features</classifier>
    <version>${openflowplugin.version}</version>
    <type>xml</type>
    <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>agent-impl</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>agent-api</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>agent-cli</artifactId>
      <version>${project.version}</version>
    </dependency>
  </dependencies>
</project>

FEATURES.XML:

<?xml version="1.0" encoding="UTF-8"?>
<!-- vi: set et smarttab sw=4 tabstop=4: -->
<!--
Copyright © 2017 Yoyodyne, Inc. and others. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
and is available at http://www.eclipse.org/legal/epl-v10.html
-->
<features name="odl-agent-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
  <repository>mvn:org.opendaylight.yangtools/features-yangtools/{{VERSION}}/xml/features</repository>
  <repository>mvn:org.opendaylight.controller/features-mdsal/{{VERSION}}/xml/features</repository>
  <repository>mvn:org.opendaylight.mdsal.model/features-mdsal-model/{{VERSION}}/xml/features</repository>
  <repository>mvn:org.opendaylight.netconf/features-restconf/{{VERSION}}/xml/features</repository>
  <repository>mvn:org.opendaylight.dluxapps/features-dluxapps/{{VERSION}}/xml/features</repository>
  <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin/{{VERSION}}/xml/features</repository>
  <feature name='odl-agent-api' version='${project.version}' description='OpenDaylight :: agent :: api'>
    <feature version='${mdsal.model.version}'>odl-mdsal-models</feature>
    <bundle>mvn:org.opendaylight.agent/agent-api/{{VERSION}}</bundle>
  </feature>
  <feature name='odl-agent' version='${project.version}' description='OpenDaylight :: agent'>
    <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
    <feature version='${project.version}'>odl-agent-api</feature>
    <bundle>mvn:org.opendaylight.agent/agent-impl/{{VERSION}}</bundle>
  </feature>
  <feature name='odl-agent-rest' version='${project.version}' description='OpenDaylight :: agent :: REST'>
    <feature version="${project.version}">odl-agent</feature>
    <feature version="${restconf.version}">odl-restconf</feature>
  </feature>
  <feature name='odl-agent-ui' version='${project.version}' description='OpenDaylight :: agent :: UI'>
    <feature version="${project.version}">odl-agent-rest</feature>
    <feature version="${restconf.version}">odl-mdsal-apidocs</feature>
    <feature version="${dluxapps.version}">odl-dluxapps-yangman</feature>
  </feature>
  <feature name='odl-agent-cli' version='${project.version}' description='OpenDaylight :: agent :: CLI'>
    <feature version="${project.version}">odl-agent</feature>
    <bundle>mvn:org.opendaylight.agent/agent-cli/{{VERSION}}</bundle>
  </feature>

</features>

The complete command that i used to create my own odl distro is (i don't know if it's really matter but...):

mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=opendaylight-startup-archetype -DarchetypeVersion=1.3.3-SNAPSHOT -DarchetypeRepository=http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/

Can anyone explain what's wrong?


回答1:


Notice that the error indicates namespace http://karaf.apache.org/xmlns/features/v1.4.0 which is for karaf 4.x which was introduced in the Opendaylight Nitrogen. However your features xml has namespace http://karaf.apache.org/xmlns/features/v1.2.0 which indicates you're using Opendaylight Carbon or earlier. So that means you're pulling in a features repository from Nitrogen (eg dluxapps or openflowplugin) - in the pom make sure you specify the correct dependency versions for dluxapps, openflowplugin etc for the Opendaylight version you're using (I assume Carbon).



来源:https://stackoverflow.com/questions/48272665/how-to-import-other-opendaylight-projects-in-my-own-odl-distro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!