Creating Standalone Portlets with the Lomboz Eclipse Plugin

I've used the Lomboz plugin now to create several portlet projects for Liferay, and it's worked out very well. For those who don't know what the Lomboz plugin is, it's got a rich history. It used to be pretty much the only open source way of creating Java Enterprise (then J2EE) projects in Eclipse, as it predated the Web Tools Project.

Now it works with the Web Tools Project, providing many enhancements to it. A couple of those enhancements are Eclipse server support for Liferay and a Portlet Project Facet. Together, these provide a nice development environment for standalone .war portlet projects.

The home page of the project is http://lomboz.objectweb.org, and their current release is an RC 1 for the new Eclipse Europa. This release candidate introduces support for Liferay 4.3.0, though YMMV if you're using one of the newer 4.3.X builds. For that reason, I'm going to go through using it on Liferay 4.2.

The first thing you need to do is create a server runtime. You'll first need to download either the Liferay-Tomcat bundle or the Liferay-JBoss bundle and unzip it to your machine. If you've done that, right-click in an empty spot in Eclipse's Servers tab and select New -> Server. Expand the Lomboz-Liferay portion of the tree and select the version of Liferay that you have already installed.

 



You'll then be brought to a screen allowing you to browse to where you've installed it. Do that, and then click  Finish on the Wizard. You'll now have a Liferay Server Runtime.

 



Having a server runtime doesn't help if you have no portlets to deploy. Lomboz also includes a nice portlet facet for Dynamic Web Projects. This allows you to create a standalone portlet .war project in Eclipse and deploy it to the runtime you have just created.

To create a standalone portlet project, select File -> New -> Project.... Pick Web -> Dynamic Web Project.

 



Click Next. Give your project a name and select the Liferay Portal runtime you'd earlier created. Click Next.

 



On the next page, change the Dynamic Web Module version to 2.3 and check the Portlet Facet. Then click Next.

 



Give your portlet a name, a description, define the Java package, select the portlet methods you want to implement, and select the portlet container (Liferay) you will be deploying this project to. Click Finish.

 



Your portlet project will be created. It will have the same standard layout as any Eclipse web project. You can now go in and implement your functionality.

 



When you're ready to debug your portlet, all you need to do is the same thing you'd do for a servlet application in Eclipse: right-click on the project and  select Debug on Server. Your Liferay runtime will be started in debug mode and your project will be automatically built and deployed to it. To debug your portlet, all you need to do is add it to a page.

The Lomboz plugin is a really nice addition to your Eclipse plugin toolset.