Maven:org.osgi.framework.BundleException:bundle中未解决的约束

时间:2014-05-27 10:22:14

标签: java maven


我正在开发一个有多个子项目的maven项目,在子项目中,项目是weasis-core-ui,我添加了一些罐子,我想在项目中使用它。

我通过在weasis-core-ui的pom.xml中添加依赖项来实现这一点:以下代码包含依赖项,我正在使用 的pom.xml

<dependency>
            <groupId>javax.xml.rpc</groupId>
            <artifactId>javax.xml.rpc</artifactId>
             <version>1.0.0</version>
            <scope>system</scope>
             <systemPath>E:/TestClient/WebContent/WEB-INF/lib/axis.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>Disc</groupId>
            <artifactId>Disc-Id</artifactId>
             <version>1.0.0</version>
            <scope>system</scope>
             <systemPath>E:/TestClient/WebContent/WEB-INF/lib/commons-discovery-0.2.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>JXRPC</groupId>
            <artifactId>JXRPC-Id</artifactId>
             <version>1.0.0</version>
            <scope>system</scope>
             <systemPath>E:/TestClient/WebContent/WEB-INF/lib/jaxrpc.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>SAAJ</groupId>
            <artifactId>SAAJ-Id</artifactId>
             <version>1.0.0</version>
            <scope>system</scope>
             <systemPath>E:/TestClient/WebContent/WEB-INF/lib/saaj.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>WSDL</groupId>
            <artifactId>WSDL-Id</artifactId>
             <version>1.0.0</version>
            <scope>system</scope>
             <systemPath>E:/TestClient/WebContent/WEB-INF/lib/wsdl4j.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>LOGGING</groupId>
            <artifactId>LOGGING-Id</artifactId>
             <version>1.0.0</version>
            <scope>system</scope>
             <systemPath>E:/TestClient/WebContent/WEB-INF/lib/commons-logging.jar</systemPath>
        </dependency>

清理项目,然后Maven测试,它工作正常。 但是当我运行应用程序时,我遇到了这个例外。

    27.05.2014 15:00:56.086 *INFO* [FelixStartLevel] org.weasis.core.api.internal.Activator Register Codec Plug-in: Sun java imageio
ERROR: Bundle weasis-core-ui [24] Error starting file:C:\Users\Taha-test\.m2\repository/org/weasis/core/weasis-core-ui/2.0.0-SNAPSHOT/weasis-core-ui-2.0.0-SNAPSHOT.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle weasis-core-ui [24]: Unable to resolve 24.0: missing requirement [24.0] osgi.wiring.package; (osgi.wiring.package=javax.xml.rpc))
org.osgi.framework.BundleException: Unresolved constraint in bundle weasis-core-ui [24]: Unable to resolve 24.0: missing requirement [24.0] osgi.wiring.package; (osgi.wiring.package=javax.xml.rpc)
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3984)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2045)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1299)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:304)
    at java.lang.Thread.run(Thread.java:662)
27.05.2014 15:00:56.165 *INFO* [FelixStartLevel] org.weasis.core.api.internal.Activator Register Codec Plug-in: dcm4che
org.osgi.framework.BundleException: Unresolved constraint in bundle weasis-dicom-explorer [5]: Unable to resolve 5.0: missing requirement [5.0] osgi.wiring.package; (&(osgi.wiring.package=it.cnr.imaa.essi.lablib.gui.checkboxtree)(version>=2.0.0)(!(version>=3.0.0))) [caused by: Unable to resolve 24.0: missing requirement [24.0] osgi.wiring.package; (osgi.wiring.package=javax.xml.rpc)]
ERROR: Bundle weasis-dicom-explorer [5] Error starting file:C:\Users\Taha-test\.m2\repository/org/weasis/dicom/weasis-dicom-explorer/2.0.0-SNAPSHOT/weasis-dicom-explorer-2.0.0-SNAPSHOT.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle weasis-dicom-explorer [5]: Unable to resolve 5.0: missing requirement [5.0] osgi.wiring.package; (&(osgi.wiring.package=it.cnr.imaa.essi.lablib.gui.checkboxtree)(version>=2.0.0)(!(version>=3.0.0))) [caused by: Unable to resolve 24.0: missing requirement [24.0] osgi.wiring.package; (osgi.wiring.package=javax.xml.rpc)])
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3984)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2045)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1299)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:304)
    at java.lang.Thread.run(Thread.java:662)

Cannot not start framework: java.lang.Exception: Main User Interface bundle cannot be started
Weasis cache will be cleaned at next launch.

请告诉我我做错了什么。 感谢

1 个答案:

答案 0 :(得分:0)

如果我做得对,你已经将依赖项添加到weasis-core-ui并尝试从weasis-dicom-explorer访问它?

这通常是可能的,但被认为是不好的做法(因为它要求您导出不受您控制的包)。更好的方法是将weasis-core-ui的接口定义为尽可能少地依赖第三方数据类。然而,似乎即使它被正确配置它也不会起作用,因为weasis-core-ui也存在布线问题。 当bundle在其MANIFEST.MF文件中找不到它声明为依赖的所有包时,会发生连接异常。在您的情况下&#34; javax.xml.rpc&#34;不见了。

现在发生的事情很乏味。您需要找出weasis-core-ui实际上需要javax.xml.rpc的原因。如果事实证明您的代码实际上没有使用需要此软件包的功能,那么您只需删除javax.xml.rpc的import package指令即可。如果您确实使用了需要此代码的代码,则需要找到导出该包的包或包含该包的jar - 例如Axis。

现在如何删除import语句在很大程度上取决于您如何管理MANIFEST.MF。如果您手动管理它,您只需删除该行,如果您通过maven-bundle-plugin管理它,则需要相应地更改您的pom以排除javax.xml.rpc。