OSGi有两个依赖链 - 无法解析依赖关系

时间:2014-03-27 09:56:14

标签: osgi apache-felix bndtools amdatu

我们使用bdntools和eclipse将OSGi用于休息应用程序。我们已经部署了应用程序,一切正常。

Uses constraint violation. 
Unable to resolve resource org.apache.felix.http.whiteboard [org.apache.felix.http.whiteboard ver=2.2.0]
because it is exposed to package 'javax.servlet' from resources
org.amdatu.multitenant.org.apache.felix.http.jetty [org.amdatu.multitenant.org.apache.felix.http.jetty ver=1.0.0]
and org.apache.felix.http.jetty [org.apache.felix.http.jetty ver=2.2.0] via two dependency chains.

我们经常遇到这个问题,通常是通过创建一个新的运行描述符来解决,但不是这次..

这是bndtools中的错误还是我们做错了什么?我们还有一种印象,它可能与多个存储库有关。

修改 这是运行描述符,是捆绑包的清单。

运行描述符:

-runfw: org.apache.felix.framework;version='[4,5)'
-runee: JavaSE-1.7
-runsystemcapabilities: ${native_capability}

-resolve.effective: active

-runrequires: osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.http.jetty)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.http.whiteboard)'

清单org.apache.felix.http.jetty:

Manifest-Version: 1.0
Export-Package: org.apache.felix.http.api;uses:="javax.servlet,org.osg
i.service.http";version="2.0.4",org.osgi.service.http;uses:="javax.se
rvlet.http,javax.servlet";version="1.2",javax.servlet.resources;versi
on="2.5",javax.servlet;version="2.5",javax.servlet.jsp.resources;vers
ion="2.5",javax.servlet.http;uses:="javax.servlet";version="2.5"
Built-By: fmeschbe
Tool: Bnd-0.0.357
Bundle-Name: Apache Felix Http Jetty
Created-By: Apache Maven Bundle Plugin
Bundle-Vendor: The Apache Software Foundation
DynamicImport-Package: org.osgi.service.cm;version=1.2
Build-Jdk: 1.6.0_13
Bundle-Version: 2.2.0
Bnd-LastModified: 1296053619491
Bundle-Activator: org.apache.felix.http.jetty.internal.JettyActivator
Bundle-ManifestVersion: 2
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Description: Apache Felix is an OSGi implementation.
Bundle-DocURL: http://www.apache.org/
Bundle-SymbolicName: org.apache.felix.http.jetty
Import-Package: javax.net.ssl;resolution:=optional,javax.security.cert
;resolution:=optional,javax.servlet;resolution:=optional;version="2.5
",javax.servlet.http;resolution:=optional;version="2.5",javax.servlet
.jsp.resources;resolution:=optional;version="2.5",javax.servlet.resou
rces;resolution:=optional;version="2.5",javax.xml.parsers;resolution:
=optional,org.apache.felix.http.api;resolution:=optional;version="2.0
",org.osgi.framework;resolution:=optional;version="1.3",org.osgi.serv
ice.http;resolution:=optional;version="1.2",org.osgi.service.log;reso
lution:=optional;version="1.3",org.osgi.util.tracker;resolution:=opti
onal;version="1.3",org.slf4j;resolution:=optional,org.xml.sax;resolut
ion:=optional,org.xml.sax.helpers;resolution:=optional

清单org.amdatu.multitenant.org.apache.felix.http.jetty:

Manifest-Version: 1.0
Bnd-LastModified: 1338812262683
Build-Jdk: 1.6.0_32
Built-By: ?
Bundle-Activator: org.amdatu.tenant.adapter.MultiTenantBundleActivator
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.html
Bundle-ManifestVersion: 2
Bundle-Name: Amdatu Web - Multi-Tenant HttpService
Bundle-SymbolicName: org.amdatu.multitenant.org.apache.felix.http.jetty
Bundle-Version: 1.0.0
Created-By: Apache Maven Bundle Plugin
Embed-Dependency: *;scope=compile;inline=true
Embed-Transitive: false
Export-Package: org.apache.felix.http.api;uses:="javax.servlet,org.osgi.
service.http";version="2.0.4",org.osgi.service.http;uses:="javax.servle
t.http,javax.servlet";version="1.2",javax.servlet.resources;version="2.
5",javax.servlet;version="2.5",javax.servlet.jsp.resources;version="2.5
",javax.servlet.http;uses:="javax.servlet";version="2.5"
Import-Package: javax.net.ssl;resolution:=optional,javax.security.cert;r
esolution:=optional,javax.servlet;resolution:=optional;version="2.5",ja
vax.servlet.http;resolution:=optional;uses:="javax.servlet";version="2.
5",javax.servlet.jsp.resources;resolution:=optional;version="2.5",javax
.servlet.resources;resolution:=optional;version="2.5",javax.xml.parsers
;resolution:=optional,org.amdatu.tenant;version="[1.0,2)",org.amdatu.te
nant.adapter;version="[1.0,2)",org.apache.felix.http.api;resolution:=op
tional;uses:="javax.servlet,org.osgi.service.http";version="2.0",org.os
gi.framework;resolution:=optional;version="1.3",org.osgi.service.cm;res
olution:=optional;version="1.2",org.osgi.service.http;resolution:=optio
nal;uses:="javax.servlet.http,javax.servlet";version="1.2",org.osgi.ser
vice.log;resolution:=optional;version="1.3",org.osgi.util.tracker;resol
ution:=optional;version="1.3",org.slf4j;resolution:=optional,org.xml.sa
x;resolution:=optional,org.xml.sax.helpers;resolution:=optional
Tool: Bnd-1.50.0
X-MultiTenant-Binding: PLATFORM
X-MultiTenant-Bundle-Activator: org.apache.felix.http.jetty.internal.Jet
tyActivator
X-MultiTenant-Scope: (&(objectClass=org.osgi.service.log.LogService)(|(o
rg.amdatu.tenant.pid=%TENANTPID%)(!(org.amdatu.tenant.pid=*))))
X-MultiTenant-Version: 1

白板清单:

Manifest-Version: 1.0
Bnd-LastModified: 1386080857007
Build-Jdk: 1.7.0_40
Built-By: jawi
Bundle-Activator: org.apache.felix.http.whiteboard.internal.WhiteboardAc
 tivator
Bundle-Description: Apache Felix is an OSGi implementation.
Bundle-DocURL: http://www.apache.org/
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-ManifestVersion: 2
Bundle-Name: Apache Felix Http Whiteboard
Bundle-SymbolicName: org.apache.felix.http.whiteboard
Bundle-Vendor: The Apache Software Foundation
Bundle-Version: 2.2.2
Created-By: Apache Maven Bundle Plugin
Embed-Dependency: org.apache.felix.http.base;inline=org/apache/felix/htt
 p/base/internal/AbstractActivator*.class|org/apache/felix/http/base/int
 ernal/logger/*
Export-Package: org.apache.felix.http.whiteboard;version="1.0"
Implementation-Title: Apache Felix Http Whiteboard
Implementation-Vendor: The Apache Software Foundation
Implementation-Vendor-Id: org.apache.felix
Implementation-Version: 2.2.2
Import-Package: javax.servlet,javax.servlet.http,org.apache.felix.http.a
 pi;version="[2.0,3)",org.osgi.framework;version="[1.5,2)",org.osgi.serv
 ice.http;version="[1.2,2)",org.osgi.service.log;version="[1.3,2)",org.o
 sgi.util.tracker;version="[1.4,2)"
Specification-Title: Apache Felix Http Whiteboard
Specification-Vendor: The Apache Software Foundation
Specification-Version: 2.2.2
Tool: Bnd-1.50.0

2 个答案:

答案 0 :(得分:1)

好吧,在repositories.bnd中似乎存在一个错误(在我看来)。看来amdatu发布存储库需要高于依赖项和快照。以下更改解决了这个错误:

-plugin:\
aQute.bnd.deployer.repository.LocalIndexedRepo; name=Release;      local=${workspace}/cnf/releaserepo;pretty=true,\
aQute.bnd.deployer.repository.LocalIndexedRepo; name=Local;        local=${workspace}/cnf/localrepo;pretty=true,\
    aQute.bnd.deployer.repository.FixedIndexedRepo; name=Bndtools Hub; locations=https://github.com/bndtools/bundle-hub/raw/master/index.xml.gz,\
    aQute.bnd.deployer.repository.FixedIndexedRepo; name=Amdatu Dependencies; locations=http://repository.amdatu.org/dependencies/index.xml.gz,\
    aQute.bnd.deployer.repository.FixedIndexedRepo; name=Amdatu Snapshots; locations=http://repository.amdatu.org/snapshot/index.xml.gz,\
    aQute.bnd.deployer.repository.FixedIndexedRepo; name=Amdatu Release; locations=http://repository.amdatu.org/release/index.xml.gz,\
    aQute.lib.deployer.FileRepo;                    name=Build;        location=${workspace}/cnf/buildrepo

-releaserepo: Release

-plugin:\
    aQute.bnd.deployer.repository.LocalIndexedRepo; name=Release;      local=${workspace}/cnf/releaserepo;pretty=true,\
    aQute.bnd.deployer.repository.LocalIndexedRepo; name=Local;        local=${workspace}/cnf/localrepo;pretty=true,\
    aQute.bnd.deployer.repository.FixedIndexedRepo; name=Bndtools Hub; locations=https://github.com/bndtools/bundle-hub/raw/master/index.xml.gz,\
    aQute.bnd.deployer.repository.FixedIndexedRepo; name=Amdatu Release; locations=http://repository.amdatu.org/release/index.xml.gz,\
    aQute.bnd.deployer.repository.FixedIndexedRepo; name=Amdatu Dependencies; locations=http://repository.amdatu.org/dependencies/index.xml.gz,\
    aQute.bnd.deployer.repository.FixedIndexedRepo; name=Amdatu Snapshots; locations=http://repository.amdatu.org/snapshot/index.xml.gz,\
    aQute.lib.deployer.FileRepo;                    name=Build;        location=${workspace}/cnf/buildrepo

-releaserepo: Release

答案 1 :(得分:0)

这里的问题正在发生,因为资源可以使用javax.servlet org.amdatu.multitenant.org.apache.felix.http.jetty org.amdatu.multitenant.org.apache.felix.http.jetty ver = 1.0.0 and org.apache.felix.http.jetty org.apache.felix .http.jetty ver = 2.2.0,因此模块org.apache.felix.http.whiteboard不知道要连接哪个javax.servlet。你可以通过删除重复来解决问题。