You are here

M2E plugin doesn't work with tomcat server

on Sep 10, 2011

There is an issue for M2E (version to generate correct eclipse configuration files especially the .classpath. Once imported a maven project, it will generate the .classpath like below:
    <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
But this will cause the eclipse server runtime like tomcat cannot find those jar libraries. After add the dynamic web application to the server from the server view, and start the server, it will throw exceptions like
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
If we check the workspace
$ lla ~/ibm_workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/test-webapp/WEB-INF
There is no folder /lib.
To resovle this problem, just install the m2e-wtp connector. It can be done by open the eclipse Preference -> Maven -> Discovery -> Open Catalog, and find the one Maven Integration for WTP, the version currently is
After installation, run Maven -> Update project configuration again, the .classpath entry will be generated like:
    <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
            <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
Now click Publish on tomcat server, we can find those denpendent libraries were deployed to workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/test-webapp/WEB-INF/lib
And the application can start successfully now.