Bundle won't find DataSource when loaded from KAR

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Bundle won't find DataSource when loaded from KAR

Steve Leach
This post has NOT been accepted by the mailing list yet.
Hi all

I am working with an application that is built as a number of bundles, which are all loading and working fine.  One of them uses a JDBC DataSources that it looks up from the environment using pax-jdbc-config. Again, this all works fine, when I simply drop the individual bundles into the deploy folder.

However, when I package the same bundles into a KAR file (using karaf-maven-plugin) and deploy that KAR, it fails to find the DataSource and so the bundle fails to load, which means the KAR fails to load.

2017-09-08T13:19:46,117 | WARN  |            | org.apache.karaf.kar.core (35) KarServiceImpl                   | Unable to install Kar feature wss-osgi-kar/1.0.4.SNAPSHOT
org.osgi.service.resolver.ResolutionException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=wss-osgi-kar; type=karaf.feature; version="[1.0.4.SNAPSHOT,1.0.4.SNAPSHOT]"; filter:="(&(osgi.identity=wss-osgi-kar)(type=karaf.feature)(version>=1.0.4.SNAPSHOT)(version<=1.0.4.SNAPSHOT))" [caused by: Unable to resolve wss-osgi-kar/1.0.4.SNAPSHOT: missing requirement [wss-osgi-kar/1.0.4.SNAPSHOT] osgi.identity; osgi.identity=uk.co.stwater.api.wss-osgi-userdb-provider; type=osgi.bundle; version="[1.0.4.SNAPSHOT,1.0.4.SNAPSHOT]"; resolution:=mandatory [caused by: Unable to resolve uk.co.stwater.api.wss-osgi-userdb-provider/1.0.4.SNAPSHOT: missing requirement [uk.co.stwater.api.wss-osgi-userdb-provider/1.0.4.SNAPSHOT] osgi.service; objectClass=javax.sql.DataSource; effective:=active; filter:="(osgi.jndi.service.name=wss)"]]

The service is available, of course...

karaf@root()> service:list javax.sql.DataSource                                                                                                                                                  14:36:10
[javax.sql.DataSource]
----------------------
 databaseName = wss
 dataSourceName = wss
 felix.fileinstall.filename = ****/etc/org.ops4j.datasource-wss-mysql.cfg
 osgi.jdbc.driver.class = com.mysql.jdbc.Driver
 osgi.jdbc.driver.name = mysql
 osgi.jndi.service.name = wss
 password = ******
 service.bundleid = 89
 service.factoryPid = org.ops4j.datasource
 service.id = 234
 service.pid = org.ops4j.datasource.3710f7cb-418e-4898-bcf6-3d4dc1ba4307
 service.scope = singleton
 url = jdbc:mysql://localhost:3306/wss
 user = root
Provided by :
 OPS4J Pax JDBC Config (89)


If I remove that one bundle from the KAR, deploy the KAR, then deploy the bundle, it all works.

What sort of things might cause a bundle to be able to resolve services when deployed individually, but not when deployed as a KAR?

Thanks in advance,
Steve