You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Borut Bolčina <bo...@gmail.com> on 2010/11/18 11:21:26 UTC

Search order for cayenne.xml

Hi,

before looking into the source code, maybe someone can help me understand
the order of search paths when adding a classpath like this

        DefaultConfiguration conf = new
DefaultConfiguration();
        conf.addClassPath("database");
        Configuration.initializeSharedConfiguration(conf);

the log spits out

[2010/11/18 11:01:03.348] DEBUG [conf.DefaultConfiguration:<init>]: using
domain file name: cayenne.xml
[2010/11/18 11:01:03.350] DEBUG [conf.DefaultConfiguration:initialize]:
initialize starting.
[2010/11/18 11:01:03.351] DEBUG [util.ResourceLocator:findResource]:
searching additional classpaths: [database]
[2010/11/18 11:01:03.351] DEBUG [util.ResourceLocator:findResource]:
searching for: database/cayenne.xml
[2010/11/18 11:01:03.352] DEBUG [mortbay.log:debug]:
getResource(database/cayenne.xml)=file:/C:/Users/borutb/workspace/maps-manager/target/classes/database/cayenne.xml
[2010/11/18 11:01:03.352] DEBUG [util.ResourceLocator:findURLInClassLoader]:
URL found with classloader:
file:/C:/Users/borutb/workspace/maps-manager/target/classes/database/cayenne.xml

So, if I do

conf.addClassPath("database");

is Cayenne also trying to load cayenne.xml from the root classpath or not?
The log says: "searching additional classpths..."

I am asking this because I have a JAR which my web project depends on and
this jar has cayenne.xml also (at the root). I just wanna be sure if the
order is deterministic and if the root is searched at all in the above case.
If not, I suggest log improvement and the documentation at
http://cayenne.apache.org/doc30/customizing-configuration.html which doesn't
clarify my case.

Thanks,
Borut

Re: Search order for cayenne.xml

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Nov 18, 2010, at 12:21 PM, Borut Bolčina wrote:

> conf.addClassPath("database");
> 
> is Cayenne also trying to load cayenne.xml from the root classpath or not?

Yes.


> The log says: "searching additional classpths..."
> 
> I am asking this because I have a JAR which my web project depends on and
> this jar has cayenne.xml also (at the root). I just wanna be sure if the
> order is deterministic and if the root is searched at all in the above case.

The order is deterministic as long as there's no multiple cayenne.xml files at the root or any given classpath location.

Andrus