You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by bsaffel <br...@ihg.com> on 2009/01/29 15:16:15 UTC

FileNotFoundException for resources in bundle

I am somewhat new to the Felix platform and am having an interesting issue
where I have created a basic bundle which is simply being used to wrap some
third party libraries and perform some simple configuration tasks with
spring.  However, when I attempt to access a set of .properties files inside
the bundle from the classpath, I receive a FileNotFoundException.

I have attempted to get to this file in every way I can think of from basic
File IO utilities to creating a Spring DM OsgiBundleResource object around
it. The file is visible in the sense that the classloader can see it, and I
can retrieve its associated URI.  The failure point seems to be at the point
the system attempts to associate a File handle with the properties file in
question.

Does anyone have any ideas as to what could be going on here?
-- 
View this message in context: http://www.nabble.com/FileNotFoundException-for-resources-in-bundle-tp21727663p21727663.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: FileNotFoundException for resources in bundle

Posted by Rob Walker <ro...@ascert.com>.
Not sure I fully understand what you are trying.

If you want a File object to the .properties file, I don't know of an 
OSGi standard way to do it.

You can get a URL resource reference to access the contents of the file 
in a number of ways though e.g,

Bundle.getResource(String name)
Bundle.getResources(String name)
xxxx.class.getClassLoader().getResource("resources/www" + baseUri + name);

-- Rob

bsaffel wrote:
> I am somewhat new to the Felix platform and am having an interesting issue
> where I have created a basic bundle which is simply being used to wrap some
> third party libraries and perform some simple configuration tasks with
> spring.  However, when I attempt to access a set of .properties files inside
> the bundle from the classpath, I receive a FileNotFoundException.
>
> I have attempted to get to this file in every way I can think of from basic
> File IO utilities to creating a Spring DM OsgiBundleResource object around
> it. The file is visible in the sense that the classloader can see it, and I
> can retrieve its associated URI.  The failure point seems to be at the point
> the system attempts to associate a File handle with the properties file in
> question.
>
> Does anyone have any ideas as to what could be going on here?
>   

-- 


Ascert - Taking systems to the Edge
robw@ascert.com
+44 (0)20 7488 3470
www.ascert.com


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: CORRECTION Re: FileNotFoundException for resources in bundle

Posted by "Richard S. Hall" <he...@ungoverned.org>.
It sounds like you are saying you want to get a File object from 
something embedded in your bundle JAR file.

If so, you cannot do that and what Rob says below is your only option.

-> richard

Rob Walker wrote:
> Not sure I fully understand what you are trying.
>
> If you want a File object to the .properties file, I don't know of an
> OSGi standard way to do it.
>
> You can get a URL resource reference to access the contents of the file
> in a number of ways though e.g,
>
> Bundle.getResource(String name)
> Bundle.getResources(String name)
>
> Sorry - last example should have read:
>
> xxxx.class.getClassLoader().getResource(String name);
>
> -- Rob
>
> bsaffel wrote:
>> I am somewhat new to the Felix platform and am having an interesting 
>> issue
>> where I have created a basic bundle which is simply being used to 
>> wrap some
>> third party libraries and perform some simple configuration tasks with
>> spring.  However, when I attempt to access a set of .properties files 
>> inside
>> the bundle from the classpath, I receive a FileNotFoundException.
>>
>> I have attempted to get to this file in every way I can think of from 
>> basic
>> File IO utilities to creating a Spring DM OsgiBundleResource object 
>> around
>> it. The file is visible in the sense that the classloader can see it, 
>> and I
>> can retrieve its associated URI.  The failure point seems to be at 
>> the point
>> the system attempts to associate a File handle with the properties 
>> file in
>> question.
>>
>> Does anyone have any ideas as to what could be going on here?
>>   
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


CORRECTION Re: FileNotFoundException for resources in bundle

Posted by Rob Walker <ro...@ascert.com>.
Not sure I fully understand what you are trying.

If you want a File object to the .properties file, I don't know of an
OSGi standard way to do it.

You can get a URL resource reference to access the contents of the file
in a number of ways though e.g,

Bundle.getResource(String name)
Bundle.getResources(String name)

Sorry - last example should have read:

xxxx.class.getClassLoader().getResource(String name);

-- Rob

bsaffel wrote:
> I am somewhat new to the Felix platform and am having an interesting issue
> where I have created a basic bundle which is simply being used to wrap some
> third party libraries and perform some simple configuration tasks with
> spring.  However, when I attempt to access a set of .properties files inside
> the bundle from the classpath, I receive a FileNotFoundException.
>
> I have attempted to get to this file in every way I can think of from basic
> File IO utilities to creating a Spring DM OsgiBundleResource object around
> it. The file is visible in the sense that the classloader can see it, and I
> can retrieve its associated URI.  The failure point seems to be at the point
> the system attempts to associate a File handle with the properties file in
> question.
>
> Does anyone have any ideas as to what could be going on here?
>   

-- 


Ascert - Taking systems to the Edge
robw@ascert.com
+44 (0)20 7488 3470
www.ascert.com



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org