Ja fiz essa pergunta um dia aqui mas não conseguiram me ajudar, com é o seguinte, estou tetando fazer um projeto de teste com Spring usando annotations, coloquei os listerners do spring no web.xml, e ja configurei tudo, mas o que ocorre é o seguinte, o spring não consegue carregar o applicationContext do WEB-INF, ele só encotra o arquivo se eu coloca na pasta “src”, mas os listerners do Spring só procuram o arquivo no WEB-INF, se eu tiro de lá da erro.ALguem sabe como resolver isso?
ja tentei e algumas formas como criar um init-param
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(.getInitParameter(“param”) });
new String[] { getServletConfig()
tentei usar request.getRealPath()+/WEB-INF/applicationContext.xml
todas essas formas dão o erro:
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [WEB-INF/applicationContext.xml] cannot be opened because it does not exist
meu web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Annotations</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<servlet>
<description></description>
<display-name>Teste</display-name>
<servlet-name>Teste</servlet-name>
<servlet-class>pack.Teste</servlet-class>
<init-param>
<description>This is an init parameter example</description>
<param-name>param</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Teste</servlet-name>
<url-pattern>/Teste</url-pattern>
</servlet-mapping>
</web-app>
meu applicationContext
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config/>
<bean class="pack.Classe1" />
<bean class="pack.Classe2"/>
</beans>
agradeço desde ja