Menu

#1 CacheConfiguration not finding properties file as resource

open
nobody
None
5
2004-07-28
2004-07-28
No

Hello -
I ran into a problem with CacheConfiguration.java

It fails when loading a configuration as a resource unless
the file is in the same package path as the
CacheConfiguration class.

For example, I am using HibernateCacheProvider with
hibernate 2.1.2.

I have cache.properties in a classes directory on my
classpath. The configuration fails to load this file.

If I move the file to
classes/org/shiftone/cache/cache.properties, then the
file is found/loaded without any problem.

I think this line:
inputStream = getClass().getResourceAsStream
(fileName);

should change to:
inputStream = getClass().getResourceAsStream("/" +
fileName);

So that fileName is interpreted as absolute fileName,
found in the classpath, instead of in a relative package
to this class.

(see http://www.javaworld.com/javaworld/javaqa/2003-
08/01-qa-0808-property.html for explanation)

Discussion


Log in to post a comment.