tags:

views:

161

answers:

2

I have code like this in Main.java :

AbstractApplicationContext context  = new ClassPathXmlApplicationContext("spring-config.xml");

until recently it was working..but i dont why it started failing with the below exception:

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring-config.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring-config.xml] cannot be opened because it does not exist

the spring-config.xml is in src/main/resources folder.

Actually i wanted to learn about the annotations: @Postconstruct and @Predestroy so i changed the build path to Jdk 1.6 from Jdk 1.5.

Since then the problem started..

Any clue guys..why it is not working?

NOTE: If any wants to see my project structure please follow this link http://code.google.com/p/javapracticeram/source/browse/trunk/SpringExample/

EDIT: alt text

A: 

This is due to spring-config.xml is not in classpath.

Add complete path of spring-config.xml to your classpath.

Also write command you execute to run your project. You can check classpath in command.

YoK
Yok,Thanks for your reply..As i mentioned in the question config file is in Resources folder which is in the build path(please see the screen shot)..How i run my project is i just run the main.jav file..and my project starts...Could you please be more specific about what u r suggesting..I could not understand..Thanks for your reply..
javanoob
@javanerd Build Path won't be used to run your program. can you also put screenshot for Run configuration you use. I assume you are running your program from eclipse.
YoK
I dont know what i did but it is working now...Thanks YoK for looking into my question[silly] :)
javanoob
A: 

Check the contents of SpringExample/target/classes. Is spring-config.xml there? If not, try manually removing the SpringExample/target/ directory, and force a rebuild with Project=>Clean... in Eclipse.

James Earl Douglas