Laliwala IT Services

Laliwala IT Services
Website Development

Wednesday, April 11, 2012

Deploying web applications in Eclipse

Since the Eclipse project was generated with the 'wtpversion' flag, it will be immediately recognized as a web application by Eclipse. If this is your first time deploying web applications in Eclipse, you will need set up your Tomcat server. To do this in Eclipse:
  1. Navigate to "Window -> Show View -> Other..."
  2. Open "Server" and select "Servers". This will open a "Servers" tab, probably in your bottom tab panel.
  3. Right-click in the new "Servers" tab and select "New -> Server"
  4. Select the version of Tomcat you installed and click "Next"
  5. Click "Browse" and locate your Tomcat installation, and click "Next"
  6. If "myportlet" isn't already in the "Configured projects" column, move it over and click "Finished"
Before we can run our portlet in Eclipse, I've found that you need to add the portlet jar to Tomcat. To do this:
  1. Right-click on the 'myportlet' project in the "Project Explorer" and select "Properties"
  2. Click on "J2EE Module Dependencies
  3. Click on the checkbox next to "M2_REPO/portlet-api/portlet-api/1.0/portlet-api-1.0.jar"
  4. Click "OK"
Now, you should be able to run and debug your project in Tomcat. The way I prefer to do this is to:
  1. Right-click on the 'myportlet' project in the "Package Explorer" and select "Run As -> Run on Server"
  2. Select the Tomcat server you set up and click "Finish"
Eclipse will now run your portlet application as if it was a servlet.

No comments:

Post a Comment