1

I am new to maven.

I am trying to import a jar dependency (com.jcraft.jsch) in my opendaylight controller project. The code compiles successfully. But when the controller is run, it throws the following errors.


!ENTRY org.opendaylight.controller.samples.ssr 4 0 2013-10-11 10:25:14.624 !MESSAGE FrameworkEvent ERROR !STACK 0 org.osgi.framework.BundleException: The bundle "org.opendaylight.controller.samples.ssr_0.4.0.SNAPSHOT [36]" could not be resolved. Reason: Missing Constraint: Import-Package: com.jcraft.jsch; version="0.0.0" at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1332) at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1316) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323) at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390) at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544) at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457) at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243) at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438) at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1) at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) 2013-10-11 10:25:14.627 IST [org.opendaylight.controller.logging.bridge.internal.LogListenerImpl@190c63b2] ERROR o.o.c.logging.bridge.OSGI2SLF4J - Bundle:org.opendaylight.controller.samples.ssr Message:FrameworkEvent ERROR Exception:org.osgi.framework.BundleException: The bundle "org.opendaylight.controller.samples.ssr_0.4.0.SNAPSHOT [36]" could not be resolved. Reason: Missing Constraint: Import-Package: com.jcraft.jsch; version="0.0.0"


I have imported that package. The package org.opendaylight.controller.samples.ssr is added by me in it. Basically, I have modified one of the packages in samples. The problem is I am trying to import one jar dependency com.jcraft.jsch in one of the classes in this package. But there is a problem with importing this jar.

I have been slogging after this issue for last couple of weeks. Any suggestions or solutions please. Thanks in advance.

4

1 回答 1

1

我在 OpenDaylight 中遇到了同样的问题。这是我经过反复试验后找到的解决方案(如果您发现任何步骤是不必要的,请告诉我):

在您的情况下,Maven 依赖项将具有,Group Id 为com.jcraft, Artifact Id 为jsch,版本为0.1.31(比如说)和 Imported Package ias com.jcraft.jsch。此外,您的 OpenDaylight 模块是org.opendaylight.controller.samples.ssr

在文件distribution/opendaylight/opendaylight-osgi-launcher.launchdistribution/opendaylight/opendaylight-osgi-launcher-local.launch中,将您的依赖项和模块添加到以下标签:

...
<stringAttribute key="target_bundles" value="com.jcraft.jsch@default:default,ch.qos.logback.classic@default:default, ch.qos.logback.core@default:default ..."/>
.
.
<stringAttribute key="workspace_bundles" value="org.opendaylight.controller.samples.ssr@default:default,org.opendaylight.controller.arphandler@default:default, ..."/>
...

在文件distribution/opendaylight/opendaylight.target中,添加一个单位条目,

...
<unit id="com.google.gson" version="2.1.0"/>
<unit id="com.jcraft.jsch" version="0.1.31"/>
...

distribution/p2site/pom.xml中,将工件条目添加为,

...
<artifact>
  <id>com.google.code.gson:gson:2.1</id>
  <transitive>false</transitive>
  <override>false</override>
</artifact>
<artifact>
  <id>com.jcraft:jsch:0.1.31</id>
  <transitive>false</transitive>
  <override>false</override>
</artifact>
...

commons/opendaylight/pom.xml中,将依赖项添加为,

...
<dependency>
  <groupId>com.google.code.gson</groupId>
  <artifactId>gson</artifactId>
  <version>2.1</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>com.jcraft</groupId>
  <artifactId>jsch</artifactId>
  <version>0.1.31</version>
</dependency>
...

做一个完整的 OpenDaylight maven 构建和运行。它应该可以正常工作。如果此依赖项具有进一步的链式依赖项,您可能会再次遇到错误。以相同的方式导入这些依赖项。

于 2013-11-13T07:24:25.433 回答