I don't think its necessarily a bad idea to load a file within the same jar.
If a file is specific to a bundle, then what's the issue in keeping it
inside the jar ? Isn't Spring keeping the application context file inside
the bundle ? Moreover, if the file is external to the bundle , then updating
the file becomes and issue as well.
On Thu, Jul 7, 2011 at 5:39 PM, Johan Edstrom-2 [via ServiceMix] <
[email protected]> wrote:

> It is not a servicemix limitation, it is an OSGi feature/benefit.
>
> Using a File to load from a jar is not a good idea either to begin with.
>
>
> On Jul 7, 2011, at 6:34 PM, Shamik Bandopadhyay wrote:
>
> > Thanks for your reply, I had the same feeling looking into it. My problem
>
> > is, I'm using a third party lib which needs a File object as an input
> param.
> > Even though I'm setting it as a Resource object through Spring, I need to
>
> > transform it to a File.
> >
> > One alternate is to externalize the files outside the bundle in a
> > pre-defined directory and then have it defined as
> > file:///....full_file_pathin spring config. But, I don't want to
> > externalize it, moreover having this
> > hard coded file path makes it difficult to work on different
> environments.
> >
> > Having said that, I'm bit surprised why would Framework like servicemix
> will
> > have such limitation? How would the problem im my case is supposed to be
> > addressed ?
> >
> >
> >
> > On Thu, Jul 7, 2011 at 5:27 PM, Johan Edstrom <[hidden 
> > email]<http://user/SendEmail.jtp?type=node&node=4563012&i=0>>
> wrote:
> >
> >> It is actually very correct.
> >> Absolute classpath like a file resource is not supported in OSGi, nor
> >> should
> >> you rely on it, you can get around it in equinox, but containers like
> >> Knoplerfish
> >> will deliver even resources from RAM.
> >>
> >> So you want to use getting it as a resource, not a file.
> >>
> >>
> >> On Jul 7, 2011, at 6:10 PM, shamik wrote:
> >>
> >>> Hi,
> >>> I'm trying figure a way to get the absolute path of files located under
>
> >> my
> >>> project's resource folder. The file paths are injected through spring
> as
> >> :
> >>>
> >>> <property name="siteConfig" value="classpath:/Test/test.xml" />
> >>>
> >>> The directory is located under src/main/resources folder, which makes
> it
> >>> available as a classpath resource inside the bundle.
> >>>
> >>> The property is being set as a Spring Resource object inside the java
> >> class.
> >>> I'm trying to access the file following way :
> >>>
> >>> File testFile = new File(siteConfig.getURL().getPath());
> >>>
> >>> I'm passing this File object to another program which then reads it.
> >>>
> >>> siteConfig.getURL() --> bundle://249.14:1/TEST/test.xml
> >>>
> >>> testFile.getAbsolutePath() --> C:\TEST\test.xml .
> >>>
> >>> As you can see, the absolute path is just repalcing "bundle://249.14:1"
>
> >> with
> >>> "C:\", which is incorrect. As a result, when the program is trying to
> >> read
> >>> the file, it's not able to pick it up.
> >>>
> >>> Any pointers will be appreciated.
> >>>
> >>> - Thanks
> >>>
> >>> --
> >>> View this message in context:
> >>
> http://servicemix.396122.n5.nabble.com/How-to-get-absolute-classpath-of-a-file-tp4562967p4562967.html
> >>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >>
> >>
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://servicemix.396122.n5.nabble.com/How-to-get-absolute-classpath-of-a-file-tp4562967p4563012.html
>  To unsubscribe from How to get absolute classpath of a file ?, click 
> here<http://servicemix.396122.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4562967&code=c2hhbWlrYkBnbWFpbC5jb218NDU2Mjk2N3w2MzMwMTIyOA==>.
>
>


--
View this message in context: 
http://servicemix.396122.n5.nabble.com/How-to-get-absolute-classpath-of-a-file-tp4562967p4563037.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to