Reputation: 21
I am writing two OSGi bundles using Eclipse and Equinox.
My first bundle, Bundle A, is in Project: Bundle A. My second Bundle B, is in Bundle B.
Bundle B loads a file server.cfg, which is located in it's project root directory (IE: workspace/Bundle B/server.cfg).
When I execute the OSGi framework, it is executing from the workspace/ directory and Bundle B cannot find server.cfg, thus, throwing an error. It is looking in workspace/server.cfg rather than workspace/Bundle B/server.cfg.
I can change the Working Directory to be Bundle B, which will find the server.cfg file. However, Bundle B cannot then find any of Bundle A's classes, thus, throwing an error.
I'm not really sure how I can inform Bundle B of the location of the file, while still being able to access Bundle A's classes from B.
I'm using Eclipse 3.6.2.
Update:
I've solved this issue by doing the following:
Setting the Working Directory to Bundle B and then exporting/importing Bundle A in the manifest files. This seemed to work.
Upvotes: 2
Views: 379
Reputation: 931
You shouldn't have to set the working directory. Try:
URL url = bundleB.getEntry("server.cfg");
File file = new File(FileLocator.toFileURL(url).getFile());
Also make sure your server.cfg file is exported in your build.properties (Build tab of the Manifest Editor).
Upvotes: 2