jst j2ee
test plan: Support for flexible project structures
WTP LogoWTP Home
Intoduction
 

Eclipse web tools platform project supports default web project structure of maven. The following test case imports a maven web project into the eclipse workspace. Prerequisite of this test case is that maven should be installed and configured on your system.

 

Installing and configuring Maven

 

  • Download maven from http://maven.apache.org/
  • Installation instructions of maven can be found at http://maven.apache.org/start/install.html
  •  

    Structure of the Web Project

     
    Steps
    Setting up maven web project
     

    1. Unzip csrweb.zip .
    2. Create project.properties under the folder csrweb and add
      maven.eclipse.projectnatures=org.eclipse.jst.j2ee.web.WebNature
    3. Create the .j2ee file, set the webcontent folder to src/webapp and context root to csrweb.
      <?xml version="1.0" encoding="UTF-8"?>
      <j2eesettings version="600">
      <moduleversion>23</moduleversion>
      <webcontent>src/webapp</webcontent>
      <context-root>csrweb</context-root>
      </j2eesettings>
    4. Go to the csrweb folder and execute "maven eclipse" from the command prompt. This will generate .project and .classpath file.
    5. Launch eclipse
    6. Go to "window-->preferences-->Java-->Build Path-->Classpath Variables" and click "New". Enter MAVEN_REPO in the name field and browse to the $HOMEPATH/.maven/repository(C:\Documents and Settings\Administrator\.maven\repository)
    7. Import project in the Eclipse Workspace using Import->Existing project into Workspace, and point to the csrweb directory.
    8. Right click on the csrweb project and go to the properties. Go to Java Build Path and change the "Default output folder" to be csrweb/src/webapp/WEB-INF/classes. This is a temporary restriction as wtp expects the output folder to be under WEB-INF/classes.
    Make sure there are no errors in the task bar.

    Exporting the web project
     

    1. Right click on the csrweb and select Export-->WAR file.
    2. Enter destination as c:\csrweb\csrweb.war.
    3. Open the war file and make sure that the contents are exported correctly.

    Running the web project on tomcat
     

    1. Please refer to running web project on tomcat for running the project on tomcat server.
    2. Invoke the HelloWorldServlet servlet by invoking http://localhost:8080/csrweb/HelloWorldServlet . Make sure it prints "Hello World" on the web browser.