Wednesday, 19 August 2009

Developing Portlets using Eclipse. Part I

On this entries I will show you how to develop portlets, create and debug portlets, in Eclipse with the WTP plugin and Jetspeed-2 . Lately I will deploy those portlets for the Websphere Portal 6.1.

Some frameworks that I will use:
The environmentLocations that I use to use with Linux:
  • /data/eclipse/eclipseWTP -> here's the eclipse.exe
  • /data/eclipse/eXtra/Jetspeed-2.2.0 -> for Jetspeed
  • /data/workspace/groupA -> for development
Locations that I use to use with Windows:
  • c:\eclipse\eclipseWTP -> here's the eclipse.exe
  • c:\eclipse\eXtra\Jetspeed-2.2.0 -> for Jetspeed
  • c:\apps\workspace\groupA -> for developement
OK, now it's time to configure our eclipse:
  • Add a new server runtime. In eclipse "Preferences/Sever/Runtime Enviroment", add "Apache Tomcat v6.0" and use the installation of the Jetspeed as "Tomcat installation directory "/data/eclipse/eXtra/Jetspeed-2.2.0".
  • Configure the new server. Here's the most important thing, just after we create the new server, we have to edit the server configuration and then "use Tomcat installation" (the default could be "use workspace") and change the "deploy path" to point where we had the "webapps" in our Jetspeed installation "/data/eclipse/eXtra/Jetspeed-2.2.0/webapps". Also we have to change the timeout to start the server.

The portlet

In eclipse, create a new Dynamic Web Project with target runtime: "Jetspeed 2.2.0". Project name: Struts2PortletTemplate :)
OK, now change the project properties, in "Java build path"... I like this "Struts2PortletTemplate/WebContent/WEB-INF/classes" as the output folder.

This will be the web.xml: