0

I have a spring context which exports the osgi service defined under /META-INF/spring/spring-dao.xml like this

<osgi:service ref="stockDao" interface="com.test.StockDao" />` 

The question is: I want to use the above defined service in my blueprint, which is defined under location /OSGI-INF/blueprint/blueprint.xml.

<reference id="stockDao" interface="com.test.StockDao" />`

After having this configuration i get following error

java.lang.Exception: Can not resolve feature:
Unsatisfied requirement(s):
---------------------------
service:(service=com.test.StockDao)
Boohoo Database Test

at org.fusesource.fabric.agent.ObrResolver.resolve(ObrResolver.java:215)[67:org.fusesource.fabric.fabric-agent:7.2.0.redhat-024]
at org.fusesource.fabric.agent.DeploymentAgent.updateDeployment(DeploymentAgent.java:566)[67:org.fusesource.fabric.fabric-agent:7.2.0.redhat-024]
at org.fusesource.fabric.agent.DeploymentAgent.doUpdate(DeploymentAgent.java:432)[67:org.fusesource.fabric.fabric-agent:7.2.0.redhat-024]
at org.fusesource.fabric.agent.DeploymentAgent$1.run(DeploymentAgent.java:242)[67:org.fusesource.fabric.fabric-agent:7.2.0.redhat-024]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)[:1.6.0_43]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)[:1.6.0_43]
at java.util.concurrent.FutureTask.run(FutureTask.java:138)[:1.6.0_43]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)[:1.6.0_43]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)[:1.6.0_43]
at java.lang.Thread.run(Thread.java:662)[:1.6.0_43]

Currently, osgi service exported in spring beans could be referenced only by spring beans. On the other side, service exported by blueprint could be referenced only by another blueprint.

Correct me if am getting it wrong? If this is possible how do I do it.

  • Yes it's possible. If you tried to do it, then please give details of the way in which it fails. – Neil Bartlett Jun 09 '13 at 13:33
  • Thanks for adding the failure details. This looks like something going wrong with the FuseSource resolver. It seems like it picks up a requirement for the `com.test.StockDao` service from one bundle (probably by statically analysing the Blueprint XML... difficult to tell) but it is not finding the corresponding capability in the bundle that should provide it. You should probably take this to the FuseSource forums for specific help there. – Neil Bartlett Jun 11 '13 at 13:17

2 Answers2

1

I found a solution for this.

Bundle 'A' - Your spring camel context - Should have manifest entry as

Export-Service: com.test.StockDao

Bundle 'B' - Your blueprint camel context - should have manifest entry as

Import-Service: com.test.StockDao

Even though spring registers the osgi service in the ServiceRegistry, blueprint looks at the manifest entry for the exported service. So making an entry in the manifest file solves this problem.

This could be done using maven bundle plugin in respective bundles

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.3.7</version>
    <extensions>true</extensions>
    <configuration>
        <instructions>
            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
            <Private-Package>${osgi.private.pkg}</Private-Package>
            <Export-Package>${osgi.export.pkg}</Export-Package>
            <DynamicImport-Package>*</DynamicImport-Package>
            <Import-Package>${osgi.import.package}</Import-Package>
            <Export-Service>${osgi.export.service}</Export-Service>
        </instructions>
    </configuration>
</plugin>
0

This is wrong, any service registered in the service registry in OSGi is able to be consumed either via std. OSGi service mechanisms, blueprint, DS, iPOJO, etc .... You just need to reference the according Interface in your Blueprint XML. BTW. the syntax is almost the same as for the Spring-OSGi xml.

Achim Nierbeck
  • 5,265
  • 2
  • 14
  • 22