See the Import-Service, that's the requirement. You have to provide a
bundle/feature with the capability.

I will provide an example to you.

Regards
JB

On 10/05/2019 09:16, Kushal Gautam wrote:
> Hi JB:
>
> here is my MANIFEST.MF file:
>
> Manifest-Version: 1.0
> Bnd-LastModified: 1557471966933
> Build-Jdk: 1.8.0_65
> Built-By: Kushal
> Bundle-Blueprint: OSGI-INF/blueprint/blueprint.xml
> Bundle-ManifestVersion: 2
> Bundle-Name: Karaf Plugin Demo
> Bundle-SymbolicName: org.apache.karaf.plugin-demo
> Bundle-Version: 1.0.0
> Created-By: Apache Maven Bundle Plugin
> Export-Package: infrastructure;uses:="org.apache.karaf.cellar.core,org
>  .osgi.service.cm
> <http://osgi.service.cm>,services";version="1.0.0",services;version="1.0.0",u
>  tils;version="1.0.0"
> Import-Package: javax.sql,org.apache.karaf.cellar.core;version="[4.1,5
>  )",org.osgi.framework;version="[1.7,2)",org.osgi.service.blueprint;ve
>  rsion="[1.0.0,2.0.0)",org.osgi.service.cm
> <http://org.osgi.service.cm>;version="[1.5,2)",services
> Import-Service: javax.sql.DataSource;multiple:=false;filter=(osgi.jndi
>  .service.name
> <http://service.name>=dw-datasource),org.apache.karaf.cellar.core.ClusterM
>  anager;multiple:=false,org.osgi.service.cm.ConfigurationAdmin;multipl
>  e:=false
> Require-Capability: osgi.ee <http://osgi.ee>;filter:="(&(osgi.ee
> <http://osgi.ee>=JavaSE)(version=1.6))"
> Tool: Bnd-4.2.0.201903051501
>
> Regards,
> Kushal.
>
> On Fri, May 10, 2019 at 7:28 AM Jean-Baptiste Onofré
> <jeanbaptiste.ono...@gmail.com <mailto:jeanbaptiste.ono...@gmail.com>>
> wrote:
>
>     Hi,
>
>     I guess your bundle contains Requirement in META-INF/MANIFEST. Did
>     you check the feature providing the DataSource provides the
>     Capability ?
>
>     Regards
>     JB
>
>     On 09/05/2019 11:23, Kushal Gautam wrote:
>>     yes, that's very confusing.
>>
>>     As I said earlier, that I verified the existence of datasource
>>     before installing the feature. Could it be because of the pooled
>>     connection?
>>
>>     Regards,
>>     Kushal.
>>
>>     On Thursday, May 9, 2019 at 11:06:50 AM UTC+2, Jean-Baptiste
>>     Onofré wrote:
>>
>>         Hi,
>>
>>         Ok, that's weird, it means that your bundle is starting
>>         before the DataSource service is available for sure.
>>
>>         Regards
>>         JB
>>
>>         On 09/05/2019 10:56, Kushal Gautam wrote:
>>>         Hi JB:
>>>
>>>         just to confirm that availability="optional" in the service
>>>         reference did the trick. Also, one of the crazy issues was
>>>         the caching, which loaded the same old jar again and again
>>>         (even though I had refreshed and replaced the jar). I did
>>>         try with feature:repo-refresh and tried reboot as well. But,
>>>         the issue with caching persisted. I had to try in a whole
>>>         new container.
>>>
>>>         Thank you for your help. Finally, I have a workaround to
>>>         this issue.
>>>
>>>         Regards,
>>>         Kushal.
>>>
>>>         On Thu, May 9, 2019 at 8:07 AM Jean-Baptiste Onofré
>>>         <jeanbapti...@gmail.com> wrote:
>>>
>>>             By the way, did you check you don't have a race
>>>             condition like you start the bundle (installing the
>>>             feature) whereas the datasource service is not yet there ?
>>>
>>>             As workaround you can define the service ref as
>>>             optional, it will reload once the service is there.
>>>
>>>             Regards
>>>             JB
>>>
>>>             On 08/05/2019 23:00, Kushal Gautam wrote:
>>>>             Hi:
>>>>
>>>>             I have a bundle that depends on two different data
>>>>             sources; and broker as well. 
>>>>
>>>>             The bundle starts properly if I copy the osgi bundle
>>>>             into deploy folder or install it using bundle:install
>>>>             <location>. Installing the bundle this way works
>>>>             perfectly fine without any glitch.
>>>>
>>>>             Instead, I tried to install it as a feature as:
>>>>
>>>>             |
>>>>             <featurename="stats-mbean"description="Stats
>>>>             MBEAN"version="1.0.0">
>>>>                     <bundle>file:D:/temp/stats-mbean-1.0.0.jar</bundle>
>>>>             </feature>
>>>>             |
>>>>
>>>>
>>>>             I have created the datasources from
>>>>             "etc/org.ops4j.datasource-*.cfg" config files.
>>>>
>>>>             I have included the feature, and when I try to install
>>>>             the feature, I get the following error.
>>>>
>>>>             |
>>>>             [caused by:Unableto resolve stats-mbean/1.0.0:missing
>>>>             requirement
>>>>             
>>>> [stats-mbean/1.0.0]osgi.service;effective:=active;filter:="(&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name
>>>>             <http://osgi.jndi.service.name>=dw-datasource))"]]
>>>>
>>>>
>>>>             |
>>>>
>>>>
>>>>             I have referenced the datasource in my bundle's
>>>>             blueprint as:
>>>>
>>>>             |
>>>>             
>>>> <referenceid="dw"interface="javax.sql.DataSource"filter="(osgi.jndi.service.name
>>>>             <http://osgi.jndi.service.name>=dw-datasource)"/>
>>>>
>>>>             |
>>>>
>>>>
>>>>             I have tried several stuffs, but I am unable to resolve
>>>>             this issue. Strange thing is, I am able to start the
>>>>             same bundle if I install it manually (copy to deploy
>>>>             folder or bundle:install)..
>>>>
>>>>             I am not entirely sure if this is an issue of pax-jdbc.
>>>>             If so, do I need to handle such cases specifically in
>>>>             the bundle pom or feature configuration?
>>>>
>>>>             Any insights on this would be very helpful.
>>>>
>>>>             Regards,
>>>>             Kushal.
>>>>             -- 
>>>>             -- 
>>>>             ------------------
>>>>             OPS4J - http://www.ops4j.org - op...@googlegroups.com
>>>>
>>>>             ---
>>>>             You received this message because you are subscribed to
>>>>             the Google Groups "OPS4J" group.
>>>>             To unsubscribe from this group and stop receiving
>>>>             emails from it, send an email to op...@googlegroups.com.
>>>>             To view this discussion on the web visit
>>>>             
>>>> https://groups.google.com/d/msgid/ops4j/9af972cd-1d8d-42ec-9506-889d417e6c5c%40googlegroups.com
>>>>             
>>>> <https://groups.google.com/d/msgid/ops4j/9af972cd-1d8d-42ec-9506-889d417e6c5c%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>>>             For more options, visit https://groups.google.com/d/optout.
>>>             -- 
>>>             -- 
>>>             ------------------
>>>             OPS4J - http://www.ops4j.org - op...@googlegroups.com
>>>
>>>             ---
>>>             You received this message because you are subscribed to
>>>             the Google Groups "OPS4J" group.
>>>             To unsubscribe from this group and stop receiving emails
>>>             from it, send an email to op...@googlegroups.com.
>>>             To view this discussion on the web visit
>>>             
>>> https://groups.google.com/d/msgid/ops4j/96d0da11-5614-ae81-a0c4-5640b87b1b1d%40gmail.com
>>>             
>>> <https://groups.google.com/d/msgid/ops4j/96d0da11-5614-ae81-a0c4-5640b87b1b1d%40gmail.com?utm_medium=email&utm_source=footer>.
>>>             For more options, visit https://groups.google.com/d/optout.
>>>
>>>         -- 
>>>         -- 
>>>         ------------------
>>>         OPS4J - http://www.ops4j.org - op...@googlegroups.com
>>>
>>>         ---
>>>         You received this message because you are subscribed to the
>>>         Google Groups "OPS4J" group.
>>>         To unsubscribe from this group and stop receiving emails
>>>         from it, send an email to op...@googlegroups.com.
>>>         To view this discussion on the web visit
>>>         
>>> https://groups.google.com/d/msgid/ops4j/CAGv3bDf1UdWKqNphbhoxh%2B1VC%3DXtVSiKgZfoSV24aCXB%3DzxfXw%40mail.gmail.com
>>>         
>>> <https://groups.google.com/d/msgid/ops4j/CAGv3bDf1UdWKqNphbhoxh%2B1VC%3DXtVSiKgZfoSV24aCXB%3DzxfXw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>>>         For more options, visit https://groups.google.com/d/optout.
>>
>>     -- 
>>     -- 
>>     ------------------
>>     OPS4J - http://www.ops4j.org - ops4j@googlegroups.com
>>     <mailto:ops4j@googlegroups.com>
>>
>>     ---
>>     You received this message because you are subscribed to the
>>     Google Groups "OPS4J" group.
>>     To unsubscribe from this group and stop receiving emails from it,
>>     send an email to ops4j+unsubscr...@googlegroups.com
>>     <mailto:ops4j+unsubscr...@googlegroups.com>.
>>     To view this discussion on the web visit
>>     
>> https://groups.google.com/d/msgid/ops4j/5a666810-4e57-4f91-81a4-0e2c43da9f21%40googlegroups.com
>>     
>> <https://groups.google.com/d/msgid/ops4j/5a666810-4e57-4f91-81a4-0e2c43da9f21%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>     For more options, visit https://groups.google.com/d/optout.
>     -- 
>     -- 
>     ------------------
>     OPS4J - http://www.ops4j.org - ops4j@googlegroups.com
>     <mailto:ops4j@googlegroups.com>
>
>     ---
>     You received this message because you are subscribed to the Google
>     Groups "OPS4J" group.
>     To unsubscribe from this group and stop receiving emails from it,
>     send an email to ops4j+unsubscr...@googlegroups.com
>     <mailto:ops4j+unsubscr...@googlegroups.com>.
>     To view this discussion on the web visit
>     
> https://groups.google.com/d/msgid/ops4j/414dc70a-fe98-ed38-6849-83f224ad503a%40gmail.com
>     
> <https://groups.google.com/d/msgid/ops4j/414dc70a-fe98-ed38-6849-83f224ad503a%40gmail.com?utm_medium=email&utm_source=footer>.
>     For more options, visit https://groups.google.com/d/optout.
>
> -- 
> -- 
> ------------------
> OPS4J - http://www.ops4j.org - ops4j@googlegroups.com
>
> ---
> You received this message because you are subscribed to the Google
> Groups "OPS4J" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ops4j+unsubscr...@googlegroups.com
> <mailto:ops4j+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ops4j/CAGv3bDfGVzhKxniRb%3DFEEd_ZxZ61qUgXeQ6TMNK7A6QMsN0nNg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ops4j/CAGv3bDfGVzhKxniRb%3DFEEd_ZxZ61qUgXeQ6TMNK7A6QMsN0nNg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

-- 
-- 
------------------
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/6307c919-1a6a-4ee5-fc78-d79a28d8fe2d%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to