title: Java, Spring, manually instantiating Spring bean, getting "FileNotFoundException: class path resource [WEB-INF/spring.properties] cannot be opened..."
body: <p>So far I have just used Spring beans that are singletons but now I want to make it where I have a <code>scope="prototype"</code> bean and instantiate it each time I need a new instance.</p>
  
  <p>In the application context I have:</p>
  
  <pre><code>&lt;bean id="processDoNewDocSearch_Spr" class="org.jadefalcon.demo.server.processes.ProcessDoNewDocSearch_Spr" scope="prototype"/&gt;
  </code></pre>
  
  <p>The actual test bean class is:</p>
  
  <pre><code>public class ProcessDoNewDocSearch_Spr {
  
      @Resource(name = "savedsearchesService")
      private SavedSearchesService savedsearchesService;
  
      public ProcessDoNewDocSearch_Spr () {
  
      }
  
      public void Main () {
          SavedSearches ss1 = savedsearchesService.get(3);
          String test= ss1.getSearchname();
          System.out.print( "Search name: " + test);
      }
  
  
  }
  </code></pre>
  
  <p>And I am trying to instantiate it like this and call the <code>Main()</code> method:</p>
  
  <pre><code>    ApplicationContext applicationContext = new ClassPathXmlApplicationContext ( "applicationContext.xml" );
      ProcessDoNewDocSearch_Spr processDoNewDocSearch_Spr = ( ProcessDoNewDocSearch_Spr ) applicationContext.getBean ( "processDoNewDocSearch_Spr" );
      processDoNewDocSearch_Spr.Main();
  </code></pre>
  
  <p>Its not working and I am getting some error about the file WEB-INF/spring.properties not being there, when it is, there is no problem with my application when I remove everything related to the <code>ProcessDoNewDocSearch_Spr</code> class, I am wondering if I am doing this correctly. Thanks</p>
  
  <p>EDIT: Here is the error message I am getting:</p>
  
  <pre><code>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [WEB-INF/spring.properties] cannot be opened because it does not exist
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  
  root cause
  
  org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [WEB-INF/spring.properties] cannot be opened because it does not exist
      org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:78)
      org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:663)
      org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:638)
      org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407)
  </code></pre>
  
  <p>EDIT: In the root of my application I have a file called .classpath and in it I have, among other entries, </p>
  
  <pre><code>    &lt;classpathentry kind="output" path="target/spring-hibernate-mysql/WEB-INF/applicationContext.xml"/&gt;
  &lt;classpathentry kind="output" path="target/spring-hibernate-mysql/WEB-INF/spring.properties"/&gt;
      &lt;classpathentry kind="src" path="src/main/webapp/WEB-INF/spring.properties"/&gt;
      &lt;classpathentry kind="src" path="src/main/webapp/WEB-INF/applicationContext.xml"/&gt;
  </code></pre>