Won’t that still be deployed as a jar file?  Doesn’t that mean that 
“getResource()” (as opposed to “getResourceAsStream”) will fail?

From: Guillaume Nodet [mailto:[email protected]]
Sent: Tuesday, October 17, 2017 1:52 PM
To: user <[email protected]>
Subject: Re: How to put an external file on the classpath so code in karaf 
bundle can read it?

One way to achieve that is to put the config file in a fragment and attach it 
to your bundle. It will be able to access those without any problem then.

2017-10-17 22:34 GMT+02:00 KARR, DAVID <[email protected]<mailto:[email protected]>>:
I'm working on a project using Karaf 3.0.1 (can't upgrade).

A colleague has a situation where he's using an artifact that tries to load a 
properties file from the classpath using "getResource()", as opposed to 
"getResourceAsStream()".  We can't change this.

He's tried to place these properties file on disk and adding the path to that 
directory to the classpath when starting karaf.  When he steps through the 
code, it doesn't find those files.  I didn't watch his debugging steps, but he 
said that it appears to only use the bundle classloader, so augmenting the 
classpath on the karaf command line makes no difference.

I know about the ability to place ".cfg" files into karaf/etc and define 
persistent properties in a blueprint, but that doesn't help, because this 
artifact expects to find these properties files on the classpath.

What else can we do to make these files findable by "getResource()" from the 
code in the artifact?



--
------------------------
Guillaume Nodet

Reply via email to