-
Jan 28th, 2011, 08:38 AM
#1
Strange contextConfigLocation issue
Hi everybody
I have to move a Spring 1.2.9 based webapp to a new hoster and therefore from a Windows server to a FreeBSD machine. On FreeBSD the path "/home" is a softlink of "/usr/home". The tomcat is installed under "/usr/home/[username]/tomcat55"
Now, when I deploy the webapp it loads every Spring context configfile two times (and therefore fails).
In the Logfile I see that it first loads every configfile from "/usr/home/..." and overwrites it later with the same file from "/home/..."
The container is configured with contextConfigLocation in web.xml and the value "classpath*:**/AppContext-*.xml"
Logfile:
org.springframework.beans.factory.xml.XmlBeanDefin itionReader -
Loading XML bean definitions from file
[/usr/home/.../WEB-INF/classes/.../applicationContext-aclManager.xml]
... other configfiles from /usr/home/...
org.springframework.beans.factory.xml.XmlBeanDefin itionReader -
Loading XML bean definitions from file
[/home/.../WEB-INF/classes/.../applicationContext-aclManager.xml]
... loads of Overriding bean definition for bean ....
... errors because of duplicate hibernate mappings...
any ideas how to avoid this?
Thanks and cheers
Stefan
-
Jan 31st, 2011, 09:23 AM
#2
OK, I was able to work around this one, by reconfigure the contextConfigLocation value:
before: "classpath*:**/AppContext-*.xml"
after: "file:/usr/home/.../WEB-INF/**/*.hbm.xml"
It's not perfect since these values are installation dependant now and I need to make them configurable, but at least it works.
If somebody knows the cause of the problem, I would be glad to read a response!
For testing purposes I created a mini webapp that simulates the spring way of scanning the classpath with the following code.
PathMatchingResourcePatternResolver scanner = new PathMatchingResourcePatternResolver();
Resource[] resources = scanner.getResources("classpath*:**/*Context-*.xml");
for (int i = 0; i < resources.length; i++) {
out.println(resources[i]+"<br>");
}
I was quite surprised to see, that the resulting list of files was correct - they appeared just under the /usr/home-path, but not under the /home-path!
So it's still a miracle to me why all config-files were imported from /home/...
Cheers
Stefan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules