我有一個數據源功能,出口數據源作爲OSGi服務:Karaf功能安裝缺少的要求osgi.service但它的存在
> services -p 2038
OPS4J Pax JDBC Config (2038) provides:
--------------------------------------
objectClass = [org.osgi.service.cm.ManagedServiceFactory]
service.bundleid = 2038
service.id = 211
service.pid = org.ops4j.datasource
service.scope = singleton
----
databaseName = foobar
dataSourceName = fooDatasource
felix.fileinstall.filename = file:/home/foousr/apache-karaf-4.0.6/etc/org.ops4j.datasource-foo.cfg
objectClass = [javax.sql.DataSource]
osgi.jndi.service.name = fooDatasource
service.bundleid = 2038
service.factoryPid = org.ops4j.datasource
service.id = 251
service.pid = org.ops4j.datasource.b3020619-71b9-4876-94c3-477f3e4a503d
service.scope = singleton
url = jdbc:oracle:thin:@dbserver:99999/foo
user = FOOUSR
由於DS-功能,創建並註冊這個數據源服務的一部分,它還包含一個ping-DS束,我可以用它來測試數據源:
> jdbc:ping-ds fooDatasource
Ping from localhost(127.0.0.1) as FOOUSR to schema FOOUSR on dbserver/foo
我有一個使用一個藍圖捆綁數據源:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/blueprint"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0
http://svn.apache.org/repos/asf/aries/trunk/blueprint/blueprint-cm/src/main/resources/org/apache/aries/blueprint/compendium/cm/blueprint-cm-1.1.0.xsd">
<reference id="ds" interface="javax.sql.DataSource" filter="(dataSourceName=fooDatasource)"/>
<camelContext id="fooDatasourceTestContext" trace="true" xmlns="http://camel.apache.org/schema/blueprint">
<route id="fooDatasourceTest">
<from uri="timer:/fooDatasourceTest?fixedRate=true&repeatCount=1"/>
<setBody>
<simple>
select * from FOOUSR.FOOTABLE
</simple>
</setBody>
<to uri="jdbc:ds" />
<to uri="log:fooDatasourceTest?showBody=true"/>
</route>
</camelContext>
</blueprint>
當我做一個feature:install foo-datasource-test-feature
時,我收到一個錯誤,抱怨說無法找到數據源服務 - 但在那裏,我可以用我的ping-ds命令訪問它。
Error executing command: Unable to resolve root: missing requirement [root] osgi.identity;
osgi.identity=foo-datasource-test-feature; type=karaf.feature; version="[0.0.1.SNAPSHOT,0.0.1.SNAPSHOT]";
filter:="(&(osgi.identity=foo-datasource-test-feature)(type=karaf.feature)(version>=0.0.1.SNAPSHOT)(version<=0.0.1.SNAPSHOT))"
[caused by: Unable to resolve foo-datasource-test-feature/0.0.1.SNAPSHOT: missing requirement
[foo-datasource-test-feature/0.0.1.SNAPSHOT] osgi.identity; osgi.identity=com.company.project.foo-datasource-test;
type=osgi.bundle; version="[0.0.1.SNAPSHOT,0.0.1.SNAPSHOT]"; resolution:=mandatory [caused by: Unable to resolve
com.company.project.foo-datasource-test/0.0.1.SNAPSHOT: missing requirement
[com.company.project.foo-datasource-test/0.0.1.SNAPSHOT] osgi.service; effective:=active;
filter:="(&(objectClass=javax.sql.DataSource)(dataSourceName=fooDatasource))"]]
這似乎是抱怨無法找到安裝的OSGi服務的數據源:
osgi.service; effective:=active;
filter:="(&(objectClass=javax.sql.DataSource)(dataSourceName=fooDatasource))"]]
什麼奇怪的是,除了一個事實,即平DS命令我寫的作品就好了,如果我只是安裝了它所抱怨的功能中的測試包,它工作得很好。這意味着這是功能的一些問題:安裝過程本身。
在FOO-數據源測試特徵的特徵,我包括foo的核特徵,其引用DS-特徵:
FOO-數據源 - 測試 - feature.xml的:
<?xml version="1.0" encoding="utf-8"?>
<features name="foo-datasource-test" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<feature name="foo-datasource-test-feature" version="${project.version}">
<feature>foo-core-feature</feature>
<bundle>mvn:com.company.project/foo-datasource-test/${project.version}</bundle>
</feature>
</features
FOO芯-feature.xml的:
<?xml version="1.0" encoding="utf-8"?>
<features name="foo-core" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<feature name="foo-core-feature" version="${project.version}">
<feature>ds-feature</feature>
...
</feature>
</features>
DS-features.xml:
<?xml version="1.0" encoding="UTF-8"?>
<features name="ds-features" xmlns="http://karaf.apache.org/xmlns/features/v1.0.0">
<feature name="ds-feature" version="${project.version}" >
<feature>pax-jdbc-config</feature>
...
<bundle start-level="86">mvn:com.company.commons/foo-datasource/${project.version}</bundle>
</feature>
<feature name="ds-ping-datasource" version="${project.version}" >
<bundle start-level="80">mvn:com.company.commons/foo-ping-datasource/${project.version}</bundle>
<feature>pax-jdbc-config</feature>
</feature>
</features>
這會導致問題嗎?如果是這樣,由於foo-datasource-test-feature依賴於已經安裝的數據源服務,那麼在我的特性中描述這種依賴關係的正確方法是什麼呢?
使用:
Karaf版本4.0.6
駱駝版本2.16.5
UPDATE
我註釋掉參考核心功能,使剛剛束是在測試功能,它仍然抱怨。因此,這與功能依賴關係的功能無關。
我打算試試卡拉夫版本4.1.0。
UPDATE
4.1.0上沒有喜悅。作爲一個側面說明,由於activemq-client 5.14.4尚未構建,所以發生了更多問題。
activemq-client修復程序是爲5.14.4今天(https://repository.apache.org/content/repositories/releases/org/apache/activemq/activemq-client/5.14.4/)構建的,所以我切換回到使用karaf 4.1.0和我使用以下版本:activemq.version = 5.14.4 camel.version = 2.18.2 spring.version = 4.3.5.RELEASE – bmcdonald
我剛剛得到同樣的問題,只有其中Require-Capability頭自動與持久性單元捆綁在一起生成。有趣的是,它已經工作了,然後「突然」停了下來。可悲的是,卡拉夫有很多東西寫得非常糟糕。 –