Eclipse 3.7/Indigo m2e WTP integration dependency issue
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 Integr开发者_如何学Goation 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?
It looks like the packaging type of the new maven project
is jar
. If so, you could change it to war
and try.
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>
Right click on project
choose Deployment Assembly > Click Add
Choose Java build Path Entries from popup window, click Next
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.
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
精彩评论