0

I am new to Spring and writing my first code. I am getting following error while running code:

Feb 09, 2014 1:21:23 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@64964f8e: startup date [Sun Feb 09 13:21:23 IST 2014]; root of context hierarchy
Feb 09, 2014 1:21:23 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [spring.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring.xml] cannot be opened because it does not exist

I tried few combinations of moving spring.xml to different locations, same issue i found. Here is the ss of my folder structure: enter image description here

Taky
  • 5,284
  • 1
  • 20
  • 29
user3265739
  • 55
  • 1
  • 10

2 Answers2

0

Try copying spring XML to your com folder. It's searching for it in your current folder. If you are storing it in other folders then it should be on your class path and the path from root of of your project should be used while loading this file using ClasspathXmlApplicationContext. If resources folder is not in your Classpath then use Example : /resources/spring.xml in your case.

Amrish Pandey
  • 800
  • 1
  • 7
  • 11
  • I tried both , copying spring.xml to com folder and changing the path to resource/spring.xml. Still same errpr. – user3265739 Feb 09 '14 at 08:10
  • If spring.XML is in com folder then no need to specify /resources/spring.xml. – Amrish Pandey Feb 09 '14 at 08:11
  • No , actually when it was in resource folder , i mentioned wirh /resource/spring.xml .. didnt work. Then i placed it in com folder with name just spring.xml... still didnt work – user3265739 Feb 09 '14 at 08:13
  • You have 2 choices 1) copy to com folder and specify spring.xml in your class 2) let it be in resources folder and specify /resources/spring.xml in your class – Amrish Pandey Feb 09 '14 at 08:13
  • Could you please share your latest code and Classpath of your project – Amrish Pandey Feb 09 '14 at 08:16
  • C:\Users\user\Documents\NetBeansProjects\AOPTest is the actual path. Following this link http://stackoverflow.com/questions/7598623/how-to-setup-classpath-in-netbeans, i added the classpath to resources,still not working – user3265739 Feb 09 '14 at 08:22
0
  1. Make sure that resources folder is in your classpth.
  2. Change spring.xml name to /spring.xml. According this example ClassPathXmlApplicationContext require slash before path. You should configure path as absolute, not as relative.
Taky
  • 5,284
  • 1
  • 20
  • 29