>>>>> Steinar Bang <s...@dod.no>: > I have helped the TwelveMonkeys image manipulation library[1] with OSGi > support. However, when I try using I see that only the image reader > services are exported from the bundles.
> I need help figuring out why the image writer services aren't exported. > I need advice on the maven-bundle-plugin config. [snip!] > In Apache Karaf, when I look at a bundle that should provide two > services (javax.imageio.spi.ImageReaderSpi and > javax.imageio.spi.ImageWriterSpi) > it provides only javax.imageio.spi.ImageReaderSpi: > https://gist.github.com/steinarb/5c84fef1e76976e276681f6f0b697e35 > This is what I'm trying to do to provide the services: > > https://github.com/haraldk/TwelveMonkeys/blob/master/imageio/imageio-jpeg/pom.xml#L43 > However this results in the following MANIFEST.MF: > > https://gist.github.com/steinarb/5256d998721f0c9dd33d25c100bc420d#file-gistfile1-txt-L32 I have figured it out, I think. I needed to change stuff like this: <instructions> <Provide-Capability> osgi.serviceloader; osgi.serviceloader=javax.imageio.spi.ImageReaderSpi; osgi.serviceloader=javax.imageio.spi.ImageWriterSpi </Provide-Capability> </instructions> into this: <instructions> <Provide-Capability> osgi.serviceloader; osgi.serviceloader=javax.imageio.spi.ImageReaderSpi, osgi.serviceloader; osgi.serviceloader=javax.imageio.spi.ImageWriterSpi </Provide-Capability> </instructions> I.e. replace the semicolon after ImageReaderSpi with a comma, and add an extra osgi.serviceloader; before the second sercice. And then the manifest looks like this ("=" instead of "~=" in front of the second service): https://gist.github.com/steinarb/23c272a171ea7873d1a410750670b902#file-gistfile1-txt-L31 And the loaded bundle exposes two services: https://gist.github.com/steinarb/f0dae9211dd44781977bb0a32ffc317f And the service is loaded and registered. ImageIO writer lookup based on the reader, which worked fine for me in unit tests, doesn't work in OSGi. But that's because ImageIO uses ClassLoader.getSystemClassLoader() to find a class based on the fully qualified class name, and that doesn't find a class loaded with OSGi. The change that will become a PR to TwelveMonkeys, is: https://github.com/steinarb/TwelveMonkeys/commit/cdadd38e699be8e17593c5b0529dfe98c30d13af