Friday, March 18, 2011

Eclipse WTP- Maven - Sample Web App

Using WTP and Maven we can easily create web applications.


Install m2 plugin from sonatype. You can search for it in eclipse market place.

Step 1: Create a new Maven Project. "HelloApp"

Step 2: Configure the created projected for WTP by running the following command.
eclipse:eclipse -Dwtpversion=1.5










Step3: Create a tomcat server instance.

Step4: Add the "HelloApp" project to tomcat server.

Step5: Add spring mvc componets to pom.xml.

Step6: Start the server.

Some times the WTP is buggy and the server may give the following exceptions.
SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)

This exception means that the required jar containing ContextLoaderListener class is not available in the tomcat webapps folder. Publishing to tomcat should take copy the required jar's into WEB-INF/lib, but if it does not happen check the deployment assembly.


Deployment Assembly Configuration


In this case we need to go set the deployment assembly manually.

1. Go to project settings. Check your deployment assembly.














2. Add the entries from Java build path.
















3. Final Deployment setup.


Take care not to keep servlet-api related jars in deployment assembly as they are already present with tomcat.

No comments:

Post a Comment