7
votes

I've just switched over to Eclipse Indigo from Helios, and I've run in to some bother when attempting to run a Maven-enabled web project on Tomcat 6 with WTP.

I'm experiencing the classic problem of Tomcat not seeing the Maven dependencies. In Helios, the workaround was to add the Maven dependencies to the Deployment Assembly via: Project properties -> Deployment Assembly -> Add 'Java Build Path Entries' -> Maven Dependencies

Unfortunately, the option of 'Java Build Path Entries' isn't being listed, only 'Folder' and 'Project'. I'm not sure if this is intentional, or if there's something wrong with my setup.

In an attempt to remove external factors, I'm using the following setup:

  • Fresh installation of Eclipse Indigo (Mac)
  • Fresh workspace
  • m2e WTP Integration installed via Eclipse Marketplace
  • Create new Maven project
  • Add in some maven dependencies, plus some code to use them
  • Convert project to faceted form
  • Add 'Dynamic Web Module' facet
  • Maven > Update Project Configuration
  • Add to a Tomcat 6 Server
  • Run on server

At this point, I see get ClassNotFoundException relating to my missing dependencies. If I run 'mvn war:war' and include the assembled 'WEB-INF/lib' directory in the project's Deployment Assembly, then of course the dependencies are correctly picked up - fine for a quick fix, but not ideal.

Most of the problems I've read about relating to similar issues has been down to a missing WTP integration module, but that doesn't appear to be the problem for me.

Am I doing something wrong?

4
Is the packaging type of the "new maven project" jar or war?Raghuram
The packaging was JAR - I've changed to WAR and the server now correctly deploys! Post this as an answer so I can mark it as correct - Thanks.sebrichards
Posted the comment as answer.Raghuram

4 Answers

3
votes

It looks like the packaging type of the new maven project is jar. If so, you could change it to war and try.

1
votes

Here is another solution: fixed .classpath file

    <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
           <attributes>
-                   <attribute name="org.eclipse.jst.component.nondependency" value=""/>
+                   <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
            </attributes>
    </classpathentry>
1
votes

Right click on project

  1. choose Deployment Assembly > Click Add

  2. Choose Java build Path Entries from popup window, click Next

  3. Using Ctrl and mouse to select all shown lib

After that you will see changes in .classpath file.

Publish your project again in server tab.

0
votes

Another WTP tomcat related question (if packaging is WAR already but libs aren't deployed) is answered / discussed in Strange behavior of Eclipse WTP deployment of dependencies in Tomcat server