我正在一个具有多个子项目的Maven项目中,在子项目weasis-core-ui中,我添加了一些jar,要在项目中使用。

我通过在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.

请告诉我我在做什么错。
谢谢

最佳答案

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

通常这是可行的,但被认为是不好的做法(因为这需要您导出不受您控制的软件包)。更好的方法是定义weasis-core-ui的接口,以尽可能少地依赖第三方数据类。但是,似乎即使正确配置它也不起作用,因为weasis-core-ui也存在接线问题。
当捆绑包在其MANIFEST.MF文件中找不到所有声明为依赖的包时,就会发生接线异常。在您的情况下,“javax.xml.rpc”丢失。

现在来的是乏味的。您需要找出为什么weasis-core-ui实际上需要javax.xml.rpc。如果事实证明您的代码实际上并未使用需要此程序包的功能,则只需删除javax.xml.rpc的import程序包指令,一切便会正常进行。如果确实使用了需要此代码的代码,则将需要找到一个捆绑包,该捆绑包要么导出该程序包,要么导出一个包含该程序包的jar-例如Axis。

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

08-27 23:26