Pedro,
Spring does no manipulation of the classpath. It uses whatever classpath
is given to it; generally this is the current thread's context
classloader's classpath, as set by whatever environment it is in.
If there are two application context definition files with the same name
available on the classpath, then generally Spring will load whichever
one the classloader returns. If this behaviour is not acceptable, then
you have to have unique names...
Regards,
Colin
pedro.costa wrote:
>Hi all,
>
>I'm trying to load two different applicationContext xml file using ClassPathXmlApplicationContext.
>
>The files have the same name, but are on diferent class paths.
>
>What is happening is that it seams that spring is always finding the same file in both cases, regardless of the classpath that is used when creating ClassPathXmlApplicationContext.
>
>I can see it from the logs.
>
>If i change the name of one of the files, it works fine.
>
>Is this a known problem?
>
>here is the code:
>
>ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext("replica/command/beans/beans.xml");
>
>BeansMappings beansMappings = (BeansMappings)appContext.getBean("serverCommandMappings");
>
>// no problem here ...
>
>ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext("replica/server/beans.xml");
>
> Listener listener = (Listener)appContext .getBean("serverListener");
>
>// Problem! it can't find it .... it seams to have loaded the first file again.
>
>// If i use a diferent file name,it works fine.
>
>
>
>thanks,
>
>Pedro.
>
>
>
|