Search code examples
javamavendependencieskarafopendaylight

Maven + ODL osgi.wiring.package javax


I am currently working on an application on top of OpenDaylight. I want to use an ObjectDB.

But I can not activate my bundle.

opendaylight-user@root>bundle:diag
ntf-impl (171)
--------------
Status: Installed
Unsatisfied Requirements:
osgi.wiring.package; resolution:="mandatory"; filter:="(&(osgi.wiring.package=javax.jdo.annotations)(&(version>=3.1.0)(!(version>=4.0.0))))"
osgi.wiring.package; resolution:="mandatory"; filter:="(&(osgi.wiring.package=javax.persistence))"

During mvn clean install

Unresolved constraint in bundle org.opendaylight.ntf.impl [205]: Unable to resolve 205.0: missing requirement [205.0] osgi.wiring.package; (&(osgi.wiring.package=javax.jdo.annotations)(version>=3.1.0)(!(version>=4.0.0)))

I will just post you my pom.xml

<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">

  <parent>
    <groupId>org.opendaylight.controller</groupId>
    <artifactId>config-parent</artifactId>
    <version>0.3.0-SNAPSHOT</version>
    <relativePath/>
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <groupId>org.opendaylight.ntf</groupId>
  <artifactId>ntf-impl</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>bundle</packaging>
  <repositories>
        <repository>
            <id>objectdb</id>
            <name>ObjectDB Repository</name>
            <url>http://m2.objectdb.com</url>
        </repository>
    </repositories>

  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>ntf-api</artifactId>
      <version>${project.version}</version>
    </dependency>
<dependency>
    <groupId>javax.jdo</groupId>
    <artifactId>jdo-api</artifactId>
    <version>3.1</version>
</dependency>
      <dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>persistence-api</artifactId>
    <version>1.0.2</version>
</dependency>
    <dependency>
            <groupId>com.objectdb</groupId>
            <artifactId>objectdb</artifactId>
            <version>2.4.0</version>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-all</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

</project>

I tried many different dependencies. Has anyone got suggestions how I could get this running?


Solution

  • Make sure to add the relevant bundles to features.xml inside your feature, such as features/src/main/features/features.xml.

    I had a bundle dependency error with javax.jms which I fixed by adding the bundle dependencies in the features.xml as shown below.

      <feature name='odl-odlmq' version='${project.version}' description='OpenDaylight :: odlmq'>
    <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
    <feature version='${project.version}'>odl-odlmq-api</feature>
    <bundle>mvn:org.opendaylight.odlmq/odlmq-impl/${project.version}</bundle>
    <bundle dependency="true">mvn:org.apache.geronimo.specs/geronimo-jms_1.1_spec/1.1.1</bundle>
    <bundle dependency="true">mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
    </feature>
    

    Similarly add the relevant bundles for javax.jdo into features.xml and build again. The build should succeed with the errors resolved.

    Alternatively to just get this running, you may build with tests skipped.

    $ mvn clean install -DskipTests

    However, in that case, you will have to manually install the dependencies later from Karaf.