Tuesday, September 11, 2012

Eclipse and Maven breaking adding resources to Tomcat

I had an Eclipse project where I could not seem to deploy to Tomcat. After
mvn eclipse:eclipse
and opening the project I found that when I right-clicked on Tomcat and chose "Add and remove..." I got the error "There are no resources that can be added or removed from the server". When looking at the project properties under Project Facets the "Dynamic Web Module" version was set to 6.0, which is not a valid version of the servlet spec. It also warns: "Implementation of version 6.0 of project facet jst.web could not be found. Functionality will be limited."

After a lot of poking around I found that I could set up the config in pom.xml like this:

Then:
rm -rf .project .classpath .settings
mvn eclipse:eclipse
Now reopen the project in Eclipse. This creates some files under .settings. Edit .settings/org.eclipse.wst.common.project.facet.core.xml, it should look like:
<faceted-project>
  <fixed facet="jst.java">
  <fixed facet="jst.web">
  <installed facet="jst.web" version="6.0">
  <installed facet="jst.java" version="1.4">
  <installed facet="jst.java" version="1.6">
  <installed facet="jst.web" version="2.5">
</faceted-project>
Delete these two lines and save:

  <installed facet="jst.web" version="6.0">
  <installed facet="jst.java" version="1.4">
Now close and reopen the project in Eclipse. You should be able to add your module to Tomcat normally.

It feels like their should be an easier way but I'm not sure what it is...

0 Comments:

Post a Comment

<< Home