Posts tagged ‘notetoself’

Note to self: Eclipse + Maven + Tomcat

I decided once again to try out Maven but this time I wanted to use it from Eclipse and get everything automatically setup for a proper web project with automatic deploy in a Tomcat.

The first lesson was not to use the system installed version of Eclipse – it just proved too difficult when adding plugins not in the system repositories (Fedora in this case). So off to to get the latest version of Eclipse IDE for Java EE Developers.

Next I went looking for a Maven plugin to Eclipse and found m2eclipse. The important part for creating a successful web project is to install both m2eclispe Core and m2eclipse Extras. Read the m2eclipse installation instructions.

When creating a new project in Eclipse select “Maven/Maven Project”. For the archetype I selected “maven-archetype-webapp”. Go to the project properties and look in the “Project Facets” to configure the needed version of the Servlet API, etc. On one project I created I had to manually edit the .project file to get the “Project Facets” entry – I had to add the line


to convince Eclipse that I had in fact created a web project.

Now open the “Servers” view and add a new Tomcat server. Right click this new server and select “Add and Remove…”. In the new dialog box add the new project. Now click the server to start it and it should automatically deploy the new project.

Note to self: The alternatives system and Java

Using the Fedora alternatives system to make Sun’s (Oracle’s) Java the system default after installation.

sudo alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_20/bin/java 2
sudo alternatives --config java