Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 325578 - Cannot construct File with a resource URL got from the classloader of the web application
Summary: Cannot construct File with a resource URL got from the classloader of the web...
Status: CLOSED WONTFIX
Alias: None
Product: Gemini.Web
Classification: RT
Component: unknown (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-17 08:45 EDT by Violeta Georgieva CLA
Modified: 2010-09-20 11:33 EDT (History)
1 user (show)

See Also:


Attachments
test web application (2.91 KB, application/x-zip-compressed)
2010-09-17 08:47 EDT, Violeta Georgieva CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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