Hi,

I am currently using a 3rd party component in a small project of mine. This
component tries to dynamically load resources from a given URL, it does
this by trying several extensions for a base name, and returns success when
it finds a resource that matches the base name and extension. For this
dynamic loading it depends on URL.openStream(). If openStream returns
FileNotFoundException it continues looking, but if openStream returns
IOException it assumes something is wrong with the resource, stops looking
and throws an exception. This works fine in a non OSGi environment, and
also inside equinox, however it does not work inside Felix. Felix throws a
IOException with the message: "Resource does not exist" instead of a
FileNotFoundException. Compare the stack traces:

Felix:

java.io.IOException: Resource does not exist:
bundle://93.0:1/resource/myresource.stg
at
org.apache.felix.framework.URLHandlersBundleURLConnection.<init>(URLHandlersBundleURLConnection.java:131)
at
org.apache.felix.framework.URLHandlersBundleStreamHandler.openConnection(URLHandlersBundleStreamHandler.java:64)
at java.net.URL.openConnection(URL.java:945)
at java.net.URL.openStream(URL.java:1010)

Equinox:

java.io.FileNotFoundException: /resource/myresource.stg
at
org.eclipse.osgi.framework.internal.protocol.bundleresource.Handler.findBundleEntry(Handler.java:51)
at
org.eclipse.osgi.framework.internal.core.BundleResourceHandler.openConnection(BundleResourceHandler.java:175)
at java.net.URL.openConnection(URL.java:945)
at java.net.URL.openStream(URL.java:1010)

Shouldn't the appropriate exception be FileNotFoundException ?

Regards,

Irving Cordova
http://irvingc.com

Reply via email to