I am using two OSGi frameworks within a plain Java application. Both frameworks load bundles from a shared directory.
In one bundle, I load a file from the resources. I tried different ways e.g.
this.getClass().getClassLoader().getResourceAsStream(...)
FrameworkUtil.getBundle(XXX.class).getEntry(...)
FrameworkUtil.getBundle(XXX.class).getResource(...)
But it doesn't matter which of the commands I use, it all works fine at the beginning. However, after several install and uninstall steps in both frameworks. The returned InputStream is null.
I also works fine if use just one OSGi framework.
After debugging a little, I found that the Bundle a got with
FrameworkUtil.getBundle(XXX.class)
is pointing to the correct jar-file BUT when I look for the referenced bundlefile in the BundleData of the Bundle, it references the bundlefile of another bundle. The bundlefiles are temporary files of the OSGi framework (Equinox in my case), that can be found for example in the local Maven repository:
.m2\repository\org\eclipse\osgi\org.eclipse.osgi\3.6.0.v20100517\configuration\org.eclipse.osgi\bundles\29\1
Anyone has an idea what could be wrong here?