Announcement Announcement Module
No announcement yet.
FileNotFoundException - loading spring config using ClassPathResource Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • FileNotFoundException - loading spring config using ClassPathResource

    I am running an app inside Tomcat. In my web.xml I have:


    I do have /WEB-INF/applicationContext.xml in my deployment under tomcat-home/webapps/<my-app-name.

    The Java code I am using to access the context looks like:

    final Resource resource = new ClassPathResource("/WEB-INF/applicationContext.xml");
    final BeanFactory factory = new XmlBeanFactory(resource);

    I have read that /WEB-INF is not in my classpath and that I should put applicationContext.xml into /WEB-INF/classes. So I updated my web.xml so that "contextConfigLocation" was set to "applicationContext.xml" (instead of WEB-INF/context.xml), I put the applicationContext.xml into /WEB-INF/classes, and I updated my Java code to use new ClassPathResource("applicationContext.xml").

    Still "FileNotFoundException".

    What I am missing?

    I am using Tomcat 6 and Spring 2.5.4.

  • #2
    Why do you create the bean factory manually and not let Spring handle this ?


    • #3
      well that's actually the other thing I wanted to do (