Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

applicationContext classpath not found

For some reason (a shiro filter) I saved my application context file in WEB-INF folder. Everything works when I run tomcat but, when I try to get an application context from a controller using :

context = new ClassPathXmlApplicationContext(fileContext);

I receive always this exception:

IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

It seems that under ecplise I'm not able to include WEB-INF under classpath. I took a look to a lot questions here in stackoverflow but I didn't find yet a solution.

If I move the applicationContext.xml file under src/main/java folder, I'm able to get the context but, the shiro filder defined into web.xml file is not able to see the shiro bean defined under applicationContext file (I double checked and the bean is correctly worked). How can I tell to web.xml to get content from src/main/java? Or, how can I reach the applicationContext.xml

like image 276
Andrea Girardi Avatar asked Oct 04 '22 10:10

Andrea Girardi


1 Answers

WEB-INF is not in your CLASSPATH. WEB-INF/classes is. So why dont you put it in a source folder and package the application?

like image 52
maggu Avatar answered Oct 12 '22 09:10

maggu