Working with Eclipse, Maven and WTP

I spend several hours lately to get Eclipse Helios to work with Maven (m2eclipse plugin) and the Eclipse Web Tools Platform (WTP). I wanted Maven to resolve my dependencies for a web project and WTP to deploy my application on a Tomcat server automatically. Actually this should be managed by the "Maven Integration for WTP" plugin - but it doesn't ...

First of all the "Workspace Resolution" of m2eclipse seems to be not working with Eclipse Helios when dealing with web projects. This feature of the m2eclipse plugin was broken in several versions before and so it is in version 0.10.0 in combination with Eclipse 3.6. As a result the depending libraries of any web project, which are located in my workspace, are not deployed on the server automatically. I could copy them to the server's "lib" folder manually, but that is actually something I would expect Maven (and WTP) to manage for me. Second of all I experienced strange sideeffects like missing configuration files or missing libraries from transitive dependencies.

To put in all in a nutshell the buggy part seems to be the "Maven Integration for WTP". So I was searching for an alternative to get my web application deployed on a Tomcat server within eclipse correctly. I finally remembered using a plugin called "FileSync" which you can find here: http://andrei.gmxhome.de/filesync/index.html

So, how does this help solving the problem?! Instead of using the web resources of WTP I configured a Tomcat server within Eclipse to point to the folder of my application inside the "target" folder, which is created by Maven when running the "package" goal. Afterwards you can start the server and watch your application running on the server. The only problem is that changes made on the source files are not deployed on the tomcat automatically. For instance if you are changing a JSP template, the server won't get any notice of that and is not updating this template. You won't be able to see your changes.

To update the tomcat automatically you can use the FileSync plugin. Just use the synchronisation plugin to apply all changes made within your working directory to the webapp inside the "target" folder. The following description shows how to do that.

1. Build the webapp by running maven with goal "package". All depencies should be resolved by maven and the final webapp should be created within a subfolder called "target".

2. Configure your Tomcat to run the webapp by setting "Document Base" manually (instead of using WTP web resources). Try starting your application and see whether it works correctly.

3. Enable file synchronisation for your web project (by clicking on "Properties -> File Synchronisation" in the context menu of your project) and link the source "webapp" folder with the main folder of your webapp inside the "target" folder as shown below.

4. Restart your webapplication and modify a template. The FileSync plugin should keep source and target in sync and you should be able to see your changes immediately.

Properties
Sven Hoffmann

Sven Hoffmann

Mon Jul 19 02:38:00 CEST 2010 • Mon Jul 19 02:38:00 CEST 2010

Eclipse, Maven, Java, Web

Categories

subshell Blog

Stories, tips and tricks from the team at subshell.

Read More ...

Download Sophora's DeskClient for Mac and PC

The Sophora Demo Web Site "Trend 2020" is now available online. Editing Sophora’s demo site with Sophora’s unique DeskEditor, you can take a closer look at Sophora’s features

more

Article on eclipse.org.: An Editorial CMS Client Based on Eclipse RCP

Use of rich client applications based on Eclipse RCP has increased widely in recent years, both in the open source and in the commercial field. Eclipse RCP is employed more and more in sections where web clients were predominantly in use. One good example of this development is the content management system (CMS) “Sophora” from the German company subshell GmbH.

Read more