I have an osgi application (in felix) with multiple bundles. There are some common property files in one bundle and the rest of the bundles need just use them.
We use maven and spring osgi, the property files are in resouces like:
<path to bundle>/src/main/resources/
common.properties
engine.properties
...
Maven builds them inside the bundle jar normally so they should be in an application classpath, but Spring has no access to them, this fails:
<context:property-placeholder location="classpath:common.properties" />
(tried classpath*: and other combinations)
Is it really some global issue with osgi ideology and no standard way to get it working? Only hacks and workarounds like that or <osgix:cmProperties...>?
It concerns because it makes deployment harder and error-prone: you can’t deploy property files inside jars with just mvn deploy as in normal application, – you’ll have to manually copy them to the production box on each release.
With OSGi, there isn’t a universal application classpath. Although the properties are on the classpath of the bundle which contains them, they’re not necessarily on the classpath of the bundles using them.
It’s a little bit ugly, but in general exporting the ‘package’ containing the property folders will make them accessible. In this case it looks like that would be ‘.’, which is very ugly, but you could put them in a ‘properties’ directory (say), and then export a properties package. Bundles which use those properties would also need to import the properties package.
Alternatively, using the containing bundle’s classloader to look up the resource will work, although I can’t comment on what the Spring config for that would look like.