Apache Felix和org.osgi用于焊接CDI-违反约束 [英] Apache felix and org.osgi for weld cdi - constraint violation

查看:125
本文介绍了Apache Felix和org.osgi用于焊接CDI-违反约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行以下解决方案:适用于Java SE的Apache Felix + Weld.为此,我要运行焊接档案中的示例之一-weld-osgi-paint.现在,我有以下捆绑列表:

I want to do the following solution:Apache Felix + Weld for Java SE. For that I want to run one of examples from weld archive - weld-osgi-paint. For now I have the following bunle list:

cdi-api.jar
ops4j-base-lang-1.5.0.jar
pax-swissbox-core-1.8.0.jar
weld-osgi-paint-core.jar
org.apache.felix.scr-1.8.2.jar
pax-swissbox-lifecycle-1.8.0.jar
weld-osgi-paint-square.jar
javax.annotation-api-1.2.jar
org.apache.servicemix.bundles.javax-inject-1_2.jar
pax-swissbox-tracker-1.8.0.jar
weld-osgi-paint-triangle.jar
javax.el-api-2.2.4.jar
pax-cdi-api-0.11.0.jar
slf4j-api-1.7.6.jar
xbean-bundleutils-4.1.jar
javax.interceptor-api-1.2.jar
pax-cdi-extension-0.11.0.jar
slf4j-log4j12-1.7.2.jar
log4j-1.2.17.jar
pax-cdi-spi-0.11.0.jar
weld-osgi-paint-api.jar
org.osgi.compendium-4.3.1.jar
org.osgi.core-4.3.1.jar

我得到以下信息:

org.osgi.framework.BundleException:使用约束冲突.无法 解决捆绑软件修订版org.ops4j.pax.cdi.extension [9.0],因为 它从捆绑包修订版中暴露给软件包"org.osgi.framework" org.apache.felix.framework [0]和osgi.core [2.0]通过两个依赖 链条.

org.osgi.framework.BundleException: Uses constraint violation. Unable to resolve bundle revision org.ops4j.pax.cdi.extension [9.0] because it is exposed to package 'org.osgi.framework' from bundle revisions org.apache.felix.framework [0] and osgi.core [2.0] via two dependency chains.

链1:org.ops4j.pax.cdi.extension [9.0] 导入:(&(osgi.wiring.package = org.osgi.framework)(版本> = 1.7.0)(!(版本> = 2.0.0))) | 导出:osgi.wiring.package = org.osgi.framework org.apache.felix.framework [0]

Chain 1: org.ops4j.pax.cdi.extension [9.0] import: (&(osgi.wiring.package=org.osgi.framework)(version>=1.7.0)(!(version>=2.0.0))) | export: osgi.wiring.package=org.osgi.framework org.apache.felix.framework [0]

链2:org.ops4j.pax.cdi.extension [9.0] 导入:(&(osgi.wiring.package = org.osgi.util.tracker)(版本> = 1.5.0)(!(版本> = 2.0.0))) | 导出:osgi.wiring.package = org.osgi.util.tracker;用途:= org.osgi.framework osgi.cmpn [3.0] 导入:(osgi.wiring.package = org.osgi.framework) | 导出:osgi.wiring.package = org.osgi.framework osgi.core [2.0]

Chain 2: org.ops4j.pax.cdi.extension [9.0] import: (&(osgi.wiring.package=org.osgi.util.tracker)(version>=1.5.0)(!(version>=2.0.0))) | export: osgi.wiring.package=org.osgi.util.tracker; uses:=org.osgi.framework osgi.cmpn [3.0] import: (osgi.wiring.package=org.osgi.framework) | export: osgi.wiring.package=org.osgi.framework osgi.core [2.0]

还有这个

...原因:java.lang.ClassCastException: org.apache.felix.scr.impl.Activator无法转换为 org.osgi.framework.BundleActivator在 org.apache.felix.framework.Felix.createBundleActivator(Felix.java:4177)

... Caused by: java.lang.ClassCastException: org.apache.felix.scr.impl.Activator cannot be cast to org.osgi.framework.BundleActivator at org.apache.felix.framework.Felix.createBundleActivator(Felix.java:4177)

据我了解,问题是pax cdi需要org.osgi,并且不适用于apache felix.该如何解决呢?

The problem, as I understand is that pax cdi needs org.osgi and it doesn't work with apache felix. How to solve such problem?

编辑1
我不安装org.osgi.core,我有以下例外,因为org.osgi.service.packageadmin位于org.osgi.core中.

EDIT 1
Whem I don't install org.osgi.core I have the following exception, as org.osgi.service.packageadmin is in org.osgi.core.

org.osgi.framework.BundleException:捆绑中未解决的约束 org.ops4j.pax.cdi.extension [8]:无法解决8.0:丢失 要求[8.0] osgi.wiring.package; (&(osgi.wiring.package = org.ops4j.pax.cdi.spi)(版本> = 0.11.0)(!(版本> = 1.0.0))) [由于:无法解决9.0:缺少要求[9.0] osgi.wiring.package; (&(osgi.wiring.package = org.apache.xbean.osgi.bundle.util)(版本> = 3.18.0)(!(版本> = 5.0.0))) [原因:无法解决16.0:缺少要求[16.0] osgi.wiring.package; (&(osgi.wiring.package = org.osgi.service.packageadmin)(版本> = 1.2.0)(!(版本> = 2.0.0)))]]] 在 org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3826) 在org.apache.felix.framework.Felix.startBundle(Felix.java:1868)处 org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)在 org.apache.felix.framework.BundleImpl.start(BundleImpl.java:931)位于 com.techsenger.launcher.core.se.all.Launcher.startBundles(Launcher.java:146) 在 com.techsenger.launcher.core.se.all.Launcher.main(Launcher.java:60)

org.osgi.framework.BundleException: Unresolved constraint in bundle org.ops4j.pax.cdi.extension [8]: Unable to resolve 8.0: missing requirement [8.0] osgi.wiring.package; (&(osgi.wiring.package=org.ops4j.pax.cdi.spi)(version>=0.11.0)(!(version>=1.0.0))) [caused by: Unable to resolve 9.0: missing requirement [9.0] osgi.wiring.package; (&(osgi.wiring.package=org.apache.xbean.osgi.bundle.util)(version>=3.18.0)(!(version>=5.0.0))) [caused by: Unable to resolve 16.0: missing requirement [16.0] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.service.packageadmin)(version>=1.2.0)(!(version>=2.0.0)))]] at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3826) at org.apache.felix.framework.Felix.startBundle(Felix.java:1868) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:931) at com.techsenger.launcher.core.se.all.Launcher.startBundles(Launcher.java:146) at com.techsenger.launcher.core.se.all.Launcher.main(Launcher.java:60)

编辑2
我没有说我使用org.apache.felix.framework-4.0.3.jar.如Christian Schneider所说,我通过删除org.osgi.core包解决了这个问题.之后,我通过以下方式将必要的软件包添加到系统软件包中:

EDIT 2
I didn't say I use org.apache.felix.framework-4.0.3.jar. I solved the problem by removing org.osgi.core bundle as Christian Schneider said. After that I added necessary packages to system packages this way:

 String SYSTEM_PACKAGES = 
        "org.osgi.framework;version=\"1.8\"," + 
        "org.osgi.service.packageadmin;version=\"1.8\","+
        "org.osgi.framework.wiring;version=\"1.8\","+
        "javax.swing,javax.management,javax.naming,javax.xml.parsers,"+
        "org.w3c.dom,org.xml.sax,org.xml.sax.helpers";
        configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES, SYSTEM_PACKAGES);

此外,我还必须采用pax-cdi- *和其他一些版本的0.8.0.这就是我得到的:

Besides I had to take version 0.8.0 of pax-cdi-* and some others. And this is what I got:

org.osgi.framework.BundleException:束中未解决的约束 org.jboss.weld.examples.weld-osgi-paint-core [23]:无法解决 23.0:缺少要求[23.0] osgi.extender; (osgi.extender = pax.cdi)在 org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3826) 在org.apache.felix.framework.Felix.startBundle(Felix.java:1868)处 org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)在 org.apache.felix.framework.BundleImpl.start(BundleImpl.java:931)

org.osgi.framework.BundleException: Unresolved constraint in bundle org.jboss.weld.examples.weld-osgi-paint-core [23]: Unable to resolve 23.0: missing requirement [23.0] osgi.extender; (osgi.extender=pax.cdi) at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3826) at org.apache.felix.framework.Felix.startBundle(Felix.java:1868) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:931)

如何解决?我安装并启动了welse-se和weld-se-core,但这没有帮助.

How to fix it? I installed and started weld-se and weld-se-core but it didn't help.

推荐答案

问题是已安装org.osgi.core. felix框架也提供了此jar提供的软件包.因此,只需不安装thecorg.osgi.core jar.

The problem is that org.osgi.core is installed. The packages provided by this jar are also provided by the felix framework. So simply do not install thecorg.osgi.core jar.

您还需要安装pax cdi捆绑软件. Weld本身不提供cdi所需的osgi支持.

You also need to install the pax cdi bundles. Weld itself does not provide the osgi support you need for cdi.

这篇关于Apache Felix和org.osgi用于焊接CDI-违反约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆