I have a project using the standard Maven web app layout, deployed within Tomcat 8.5 in Eclipse Photon (with latest updates).
Inside of src\main\webapp\WEB-INF\applicationContext.xml
, there is an <import resource="classpath:/other-spring-stuff.xml" />
I verified the other-spring-stuff.xml
which is normally sitting in src/main/resources
, appears in the root of the WAR
generated by mvn install
.
But when trying to run the app in Tomcat within Eclipse, I get:
20:37:17 SEVERE: Servlet [servletSpringDispatcher] in web application [/myapp] threw load() exception - 2018-08-27 @{org.apache.catalina.core.StandardContext loadOnStartup}
java.io.FileNotFoundException: class path resource [spring.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:227)
I don't really know whether this is a problem with Maven, Eclipse, or Spring.
What can cause this? This is actually in a project that was working fine until yesterday, and nothing changed on the project configuration.
The original problem (spring.xml not found) and secondary problem (false report of missing web.xml) were both resolved by taking the following steps:
.project
, .classpath
, and .settings/
.project
, .classpath
, and .settings/*
from git and then add them to .gitignore
I believe the root cause is that one of these Eclipse-specific config files that was checked into the repo had become corrupted and/or incompatible with my version of Eclipse. Also: these files seem to contain absolute-path references to things in the workspace, so they break when the project is checked out unmodified to a different location.