RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Integrate the Eclipse Web Tools Platform and Maven

Leveraging the Eclipse Web Tools Platform (WTP) and the M2Eclipse (M2) plugin in the same project has compelling benefits for the Java web developer.

he Eclipse Web Tools Platform (WTP) and the M2Eclipse (M2) plugin are separate projects, each with high value for the developer who uses Eclipse. WTP is a tools bundle that extends the Eclipse platform for web and Java EE application development, while M2 integrates Maven tightly into the IDE. Leveraging both in the same project has compelling benefits for the developer. Unfortunately, Eclipse has yet to offer WTP and M2 integration OOTB (that's Out Of The Box, if you didn't know). That's where this article comes in.

This article demonstrates basic web application development using both WTP and M2 as an integrated solution. By walking through a project-building exercise from setup through deployment, it will enable you to speed up your own Eclipse-based Java web development by applying the same process.

Environment Setup
The primary development environment for the project described in this article is Eclipse. Your Eclipse environment must include the following technologies to complete the exercise.

What You Need
M2 Plugin
The latest version of Java 5
The latest versions of Tomcat
The settings file from the Maven 2 install
(available in the apache-maven-2.0.8\conf folder)

Figure 1. Server Configuration: Follow these steps to configure the server.

See Sidebar 1 for a more complete list of Eclipse download links.

WTP and M2Plugin Configurations
Before you begin, you must set some initial server, browser, and Maven configurations. In fact, when you launch Eclipse with the M2 plugin you may see an error message regarding a settings.xml file. Ignore the message. It will be resolved shortly.

Server Configuration
Configure your server to run the web application. From the Eclipse menu, follow these steps to configure the server (see Figure 1): Windows→Preferences→Server→Installed Runtimes→add.

Select the appropriate version of Tomcat. In the next page of this wizard screen, browse to the Tomcat home directory and press "finish."

Figure 2. Maven Settings: Navigate through Eclipse Menu→Window→Preference and click on Maven in the left panel.

Configure Browser
When you launch a web application using WTP, it opens in an internal browser. You may prefer to have your web applications open in an external browser of your choice. If so, configure the external browser to launch using the Eclipse menu path Window→Web Browser.

Maven2 Configurations
Navigate through Eclipse Menu→Window→Preference and click on "Maven" in the left panel. This may take a short while. If so, please wait. Note the file path mentioned in the "User Settings file" field (see Figure 2). Ensure a valid settings.xml file is present in this location. If you don't have a valid settings.xml file there, copy it from apache-maven-2.0.8\conf. Press the "OK" button.

Now you can start the actual work of creating a dynamic WTP project and integrating it with the M2 plugin.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date