Announcement Announcement Module
No announcement yet.
Strange contextConfigLocation issue Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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"

    org.springframework.beans.factory.xml.XmlBeanDefin itionReader -
    Loading XML bean definitions from file

    ... other configfiles from /usr/home/...

    org.springframework.beans.factory.xml.XmlBeanDefin itionReader -
    Loading XML bean definitions from file

    ... loads of Overriding bean definition for bean ....
    ... errors because of duplicate hibernate mappings...

    any ideas how to avoid this?

    Thanks and cheers

  • #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++) {

    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/...