我有四个捆绑包,每个捆绑包只包含一个清单。捆绑包是
app
和com.example.foo.fragment
的com.example.bar
导出foo
com.example.foo;uses:=com.example.foo.cfg
foo.fragment
这是附加到导出foo
和com.example.foo.fragment
的{{1}}的片段com.example.foo.fragment.cfg;uses:=com.example.foo.fragment
导出bar
并导入com.example.bar
捆绑级别依赖关系图:
com.example.foo
当我在JBoss AS 7.2中同时安装这些软件包时,它们工作得很好。但是,如果我在之后安装app -> bar
| |
| v
| foo
| |
v v
foo.fragment
软件包,无论是第一次,还是在成功启动然后卸载它之后,都会发生以下使用约束违规:
app
完整的清单是:
Caused by: org.osgi.service.resolver.ResolutionException: Uses constraint violation. Unable to resolve resource com.example.app [HostBundleRevision[com.example.app:0.0.
0]] because it is exposed to package 'com.example.foo.fragment' from resources com.example.foo [HostBundleRevision[com.example.foo:0.0.0]] and com.example.foo [HostBund
leRevision[com.example.foo:0.0.0]] via two dependency chains.
Chain 1:
com.example.app [HostBundleRevision[com.example.app:0.0.0]]
import: null
|
export: osgi.wiring.package=com.example.foo.fragment
com.example.foo [HostBundleRevision[com.example.foo:0.0.0]]
Chain 2:
com.example.app [HostBundleRevision[com.example.app:0.0.0]]
import: null
|
export: osgi.wiring.package=com.example.bar; uses:=com.example.foo
com.example.bar [HostBundleRevision[com.example.bar:0.0.0]]
import: null
|
export: osgi.wiring.package=com.example.foo; uses:=com.example.foo.fragment
export: osgi.wiring.package=com.example.foo.fragment
com.example.foo [HostBundleRevision[com.example.foo:0.0.0]]
at org.apache.felix.resolver.ResolverImpl.checkPackageSpaceConsistency(ResolverImpl.java:1142)
at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:197)
at org.jboss.osgi.resolver.felix.StatelessResolver.resolve(StatelessResolver.java:56)
at org.jboss.osgi.framework.internal.ResolverImpl.resolveAndApply(ResolverImpl.java:137)
at org.jboss.as.osgi.service.BundleLifecycleIntegration$BundleLifecycleImpl.activateDeferredPhase(BundleLifecycleIntegration.java:296)
... 31 more
我无法在独立的Apache Felix 4.2.1中重现上述错误。
这种行为的原因是什么?如果我从app.jar/META-INF/MANIFEST.MF
----------------------------
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.example.app
Import-Package: com.example.foo.fragment,com.example.bar
----------------------------
foo.jar/META-INF/MANIFEST.MF
----------------------------
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.example.foo
Export-Package: com.example.foo;uses:="com.example.foo.cfg"
-------------------------------------
foo.fragment.jar/META-INF/MANIFEST.MF
-------------------------------------
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.example.foo.fragment
Fragment-Host: com.example.foo
Export-Package: com.example.foo.fragment,com.example.foo.cfg;uses:="co
m.example.foo.fragment"
----------------------------
bar.jar/META-INF/MANIFEST.MF
----------------------------
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.example.bar
Export-Package: com.example.bar;uses:="com.example.foo"
Import-Package: com.example.foo
清单中删除了Fragment-Host: com.example.foo
行,我可以重新安装foo.fragment
,没有错误。这是JBoss AS 7.2中的错误吗?
答案 0 :(得分:1)
您不必在app中导入foo.fragment,您的依赖项将从foo中解析。所以只需删除该依赖项并重新部署它。这个问题是因为循环依赖。