title: Exception when using ClassPathXmlApplicationContext function
body: <p>I was using the <strong>ClassPathXmlApplicationContext</strong> to read my xml. But on execution I am getting the error as stated under . I have also  checked the file names and I  have also executed the same program using <strong>XmlBeanFactory</strong> function which returns the desired output </p>
  
  <p>Here  is my code</p>
  
  <pre><code>  package org.lalit.springsession;
  
    import org.springframework.beans.BeansException;
    import org.springframework.beans.factory.BeanFactory;
    import org.springframework.beans.factory.NoSuchBeanDefinitionException;
    import org.springframework.beans.factory.xml.XmlBeanFactory;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    import org.springframework.core.io.FileSystemResource;
  
    public class DrawingApp {
  
  public static void main(String[] args) {
      // TODO Auto-generated method stub
  
  
  
           /*
      BeanFactory factory = new XmlBeanFactory(new        FileSystemResource("spring.xml")) ;
      Triangle triangle=  (Triangle) factory.getBean("triangle");
      triangle.draw();
      */
  
      BeanFactory factoryObj = new ClassPathXmlApplicationContext("spring.xml");
      Triangle triangle=  (Triangle) factoryObj.getBean("triangle");
      triangle.draw();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>These are Exceptions which I am facing.</p>
  
  <pre><code>   May 06, 2014 1:53:42 PM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
      INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@14a1ee92: startup date [Tue May 06 13:53:42 IST 2014]; root of context hierarchy
      May 06, 2014 1:53:42 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
      INFO: Loading XML bean definitions from class path resource [C:/Users/Lalit/workspace/DemoSpring/spring.xml]
      Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [C:/Users/Lalit/workspace/DemoSpring/spring.xml]; nested exception is java.io.FileNotFoundException: class path resource [C:/Users/Lalit/workspace/DemoSpring/spring.xml] cannot be opened because it does not exist
          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:343)
          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)
          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:251)
          at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
          at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
          at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
          at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:540)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
          at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
          at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)
          at org.lalit.springsession.DrawingApp.main(DrawingApp.java:24)
          Caused by: java.io.FileNotFoundException: class path resource [C:/Users/Lalit/workspace/DemoSpring/spring.xml] cannot be opened because it does not exist
          at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:329)
          ... 13 more
  </code></pre>