I've been working alone on a project for a long time and now another developer joined so I wanted to set up the project on his machine from SVN. We are both using very similar set-ups:
The Spring version used is 2.5.6.
I set up the project on his machine using Eclipse's "Project from SVN" tool, essentially creating a 1:1 copy of the project. Maven took care of all dependencies without problems as far as I can tell, the project compiled without problems. The project structure is following the Maven standard for webapps with resources (like the applicationContext.xml) in src/main/resources, the project's code in src/main/java and all web-app related files in src/main/webapp and src/main/webapp/WEB-INF respectively.
The web.xml is configured to load the context like so:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Using the "Servers" tool of Eclipse I tried launching the application right from Eclipse, but it failed immediately with a FileNotFoundException when trying to load the applicationContext.xml.
Since the code checked out from SVN has been left untouched I guess the problem has to do with some parameter for the Maven plugin. Or that I forgot some important step to finalize the set-up. Has anybody encountered a similar issue or has an idea where I should start looking?
Thank you very much for you help!
The project structure is following the Maven standard for webapps with resources (like the applicationContext.xml) in src/main/resources, the project's code in src/main/java and all web-app related files in src/main/webapp and src/main/webapp/WEB-INF respectively.
This is correct and perfectly fine (as you want the applicationContext.xml
to be on the tests class path).
It is not copied to WEB-INF/classes, but that's not the case in my own (functioning) project. Instead, the file is copied to target/classes as per Maven-standard.
It is copied to target/yourapp/WEB-INF/classes
, but not by process-resources
which is called by default by m2eclipse on resource changes (this goal copies/filters resources to target/classes
). This happens during the package
phase (or when invoking explicitly war:war
, war:inplace
or war:exploded
). As explained in the usage page, the WAR Plugin is not responsible for compiling the java sources or copying the resources.
So I'd suggest to package
the war before to run it on a Server. Maybe you can configure m2eclipse to do this automatically on resource changes (right-click on your project, then select Properties > Maven and add the appropriate war
goal to the Goals to invoke on resource changes). Didn't try this though.