title: Class path resource cannot be opened because it does not exist
body: <p>I'm learning REST services by following a book and this is the first exercise which uses beans. I created a bean configuration file (<code>applicationContext.xml</code>) and placed it inside a /spring folder, but when I run the application it says it can't find it (as indicated by the following picture):</p>
  
  <p><a href="https://i.stack.imgur.com/CVe86.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CVe86.png" alt="enter image description here"></a></p>
  
  <p>Would anybody know what am I doing wrong?</p>
  
  <p>Stacktrace:</p>
  
  <pre><code>SEVERE: Context initialization failed
  org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring/applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring/applicationContext.xml] cannot be opened because it does not exist
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
      at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
      at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:614)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:515)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
      at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:782)
      at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:424)
      at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:774)
      at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:249)
      at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
      at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
      at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
      at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
      at org.eclipse.jetty.server.Server.doStart(Server.java:282)
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
      at net.sourceforge.eclipsejetty.starter.embedded.JettyEmbeddedAdapter.start(JettyEmbeddedAdapter.java:67)
      at net.sourceforge.eclipsejetty.starter.common.AbstractJettyLauncherMain.launch(AbstractJettyLauncherMain.java:84)
      at net.sourceforge.eclipsejetty.starter.embedded.JettyEmbeddedLauncherMain.main(JettyEmbeddedLauncherMain.java:42)
  Caused by: java.io.FileNotFoundException: class path resource [spring/applicationContext.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:330)
      ... 26 more
  
  2017-06-22 17:54:59.076:WARN:oejw.WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/,file:/C:/Users/JINK/workspace/SecondExercise/src/main/webapp/},C:\Users\JINK\workspace\SecondExercise\src\main\webapp
  org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring/applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring/applicationContext.xml] cannot be opened because it does not exist
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
      at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
      at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:614)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:515)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
      at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:782)
      at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:424)
      at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:774)
      at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:249)
      at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
      at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
      at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
      at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
      at org.eclipse.jetty.server.Server.doStart(Server.java:282)
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
      at net.sourceforge.eclipsejetty.starter.embedded.JettyEmbeddedAdapter.start(JettyEmbeddedAdapter.java:67)
      at net.sourceforge.eclipsejetty.starter.common.AbstractJettyLauncherMain.launch(AbstractJettyLauncherMain.java:84)
      at net.sourceforge.eclipsejetty.starter.embedded.JettyEmbeddedLauncherMain.main(JettyEmbeddedLauncherMain.java:42)
  Caused by: 
  java.io.FileNotFoundException: class path resource [spring/applicationContext.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:330)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
      at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
      at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:614)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:515)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
      at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:782)
      at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:424)
      at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:774)
      at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:249)
      at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
      at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
      at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
      at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
      at org.eclipse.jetty.server.Server.doStart(Server.java:282)
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
      at net.sourceforge.eclipsejetty.starter.embedded.JettyEmbeddedAdapter.start(JettyEmbeddedAdapter.java:67)
      at net.sourceforge.eclipsejetty.starter.common.AbstractJettyLauncherMain.launch(AbstractJettyLauncherMain.java:84)
      at net.sourceforge.eclipsejetty.starter.embedded.JettyEmbeddedLauncherMain.main(JettyEmbeddedLauncherMain.java:42)
  2017-06-22 17:54:59.196:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8085
  ------------------------------------------------
  Jetty startup finished in 1,4 s.
  Used memory: 5,3 MB of 123,0 MB (1,8 GB maximum)
  Console available: type "help".
  ----
  </code></pre>
  
  <hr>