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.

Categories
Sophora CMS - A New Take on Content Management
Sophora is optimized to meet the needs of modern companies that produce up-to-date multimedia content on a large scale and that require fast delivery of their content.
Toromiro
Toromiro is a professional tool for the administration and editing of Java Content Repositories (JCR). JCR is powering some of today’s most successful solutions for content management and digital asset management.