Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 325578

Summary: Cannot construct File with a resource URL got from the classloader of the web application
Product: [RT] Gemini.Web Reporter: Violeta Georgieva <milesg78>
Component: unknownAssignee: Project Inbox <gemini.web-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: glyn.normington
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
test web application none

Description Violeta Georgieva CLA 2010-09-17 08:45:57 EDT
Build Identifier: 

Hi,
I have the following scenario:
In my servlet I get a resource from the classloader:

URL resourceURL = this.getClass().getResource("resource.txt");

With the received URL I want to construct a file and to read its content:

File refourceFile = new File(resourceURL.toURI());

The result from the File construction is:

java.lang.IllegalArgumentException: URI scheme is not "file"

The problem is because the URL for the resource is returned like this

bundleresource://46.fwk30983464/test/resource.txt

The URI scheme is not known for the File, which expects the URI scheme to be "file".
In the OSGi Enterprise Specification, Web Applications Specification there are clarifications only for ServletContext.getResource() method.
I saw that in Virgo project additional equinox extension is introduced that solves this problem.

org.eclipse.virgo.osgi.extensions.equinox.hooks. ExtendedBundleFileWrapperFactoryHook

Is it possible to introduce such extension for Gemini.Web as this functionality is widely used?
Or if you consider it as expected, is it possible to document it? 

Thanks in advance.
Best Regards
Violeta


Reproducible: Always

Steps to Reproduce:
1. Start the Gemini.Web
2. In the console install the attached web application: install webbundle:file:<path-to-web-app>?Web-ContextPath=/test-app
3. Start the web application bundle
4. Request http://localhost:8080/test-app/TestServlet
5. Exception is thrown in the console: java.lang.IllegalArgumentException: URI scheme is not "file"
Comment 1 Violeta Georgieva CLA 2010-09-17 08:47:13 EDT
Created attachment 179107 [details]
test web application
Comment 2 Glyn Normington CLA 2010-09-20 04:58:33 EDT
Hi Violeta

This calls for some careful thought.

For starters, I've documented a limitation: http://wiki.eclipse.org/Gemini/Web#Limitations

Looking to the future, I am reticent to build an Equinox hook into Gemini Web since:

* I'd like to minimise the Equinox-specific code to ensure consistent behaviour on other OSGi framework implementations such as Felix,

* such a hook is likely to conflict with Equinox hooks provided by a container which embeds Gemini Web,

* the hook needs installing into Equinox earlier than Gemini Web, so this complicates the start up procedure for Gemini Web when the hook is required.

The Virgo hook is actually pretty small and users (application server implementers) who care can reuse the Virgo hook fairly easily.

So I'm closing this as WONTFIX. If compelling use cases arise, I'm happy to reconsider.

Regards,
Glyn
Comment 3 Violeta Georgieva CLA 2010-09-20 11:33:40 EDT
Thanks
Regards
Violeta