views:

679

answers:

3

I am running Eclipse Galileo with Tomcat 6.0.18.

Currently, I have a working application with the m2Eclipse plugin installed. It deploys to Tomcat and I am able to test my application.

I am wanting to switch over to just using the Maven Eclipse plugin. The problem is that Tomcat is refusing to deploy my application.

I have converted my web project to a dynamic web module and set all my build paths as close to my previous m2Eclipse workspace as possible and still no success. When I hit the url, I just get a blank page.

What I did narrow down was that in my m2Eclipse workspace, when Tomcat publishes the web project, the context.xml file in [TOMCAT_HOME]\conf\Catalina\localhost has the docBase set to the "Web Content" directory. While my Maven Eclipse workspace, the context.xml that Tomcat publishes to have the docBase set to "Java Source" directory.

What do I need to do to have my "Maven Eclipse" workspace integrated with Tomcat work successfully like my m2Eclipse workspace?

A: 

Seams you don't have proper configuration of maven-eclipse-plugin if you converted project manually to dynamic web module.

According to maven-eclipse-plugin documentation you need to specify additional configuration in your pom (or by passing -D parameters) for WTP project. Key is <wtpversion> tag.

     <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <configuration>
                    <projectNameTemplate>[artifactId]-[version]</projectNameTemplate>
                    <wtpmanifest>true</wtpmanifest>
                    <wtpapplicationxml>true</wtpapplicationxml>
                    <wtpversion>2.0</wtpversion>
                    <manifest>${basedir}/src/main/resources/META-INF/MANIFEST.MF</manifest>
            </configuration>
    </plugin>
cetnar
Hmmm. when I run the eclipse goal, it says version 2.0 isn't supported. Only 1.0 and R5.
Gary H
Support for WTP 2.0 was introduced in version 2.5 of maven-eclipse-plugin. So you need specify newer version or run Maven with -up (update plugins) flag.
cetnar
A: 

Look into using the Tomcat plugin for Eclipse.

Kelly French
A: 

I went the other way, taking an existing Eclipse Dynamic Web project and converting it to a Maven project. To get them both to work will likely involve manually editing the project files.

First choose to "Customize View" from the little arrow in your "Project Explorer" view and uncheck ".* resources" from the list of filters. This will allow you to view the contents of the .settings directory.

Open org.eclipse.wst.common.component. It's an XML file that tells the WTP project where the webapp files are located.

To make it work with Maven, you'll need it to look something like:

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
  <wb-module deploy-name="(project name)">
    <wb-resource deploy-path="/" source-path="/src/main/webapp"/>
    <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
    <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
    <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
    <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
    <property name="context-root" value="(project URL)"/>
    <property name="java-output-path"/>
  </wb-module>
</project-modules>

There are two "variables" in there that you'll probably want to leave alone - the name of the project (as it appears in the "Servers" view) and the name of the URL where the project is deployed on Tomcat.

I think that's the only change really needed to get WTP to play nice with Maven, since that tells it where to find the various files it needs to deploy to Tomcat.

Xenoveritas