0
votes

I'm new with Spring and Hibernate. I did a project from book Prospring4 But I did not a simple java application, but Dynamic web project (for future). I wrote all code and created a app-context-annotation.xml with beans. In book I have a code to load it:

GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
ctx.load("classpath:META-INF/spring/app-context-annotation.xml");

In my project I have a standart path - WebContent/META-INF and I add folder with file where. But always I get a error:

org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [META-INF/spring/app-context-annotation.xml] Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [META-INF/spring/app-context-annotation.xml]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/spring/app-context-annotation.xml] cannot be opened because it does not exist

I read many forum answers but I really don't understand WHY it happens! I tried to convert my project to Maven project, but got this error again.

PLZ tell me what I'm doing wrong?

EDIT. Ok. Now this is my project structure, but result is the same exception.

enter image description here

1
No. 'Cos there is not DYnamic web project and I don't have those folderstrashgenerator

1 Answers

0
votes

Is the Webcontent folder on your classpath? I mean, when you build your project you see app-context-annotation.xml into the classes folder? If not you should add the Webcontent folder to the build path or move the xml to another folder. p.e: src/main/java