« Voltar para Integrated...

Netbeans IDE Setup

This article needs updating. For more information, see Wiki - Need Updating.

This page uses Liferay 5.1 and Netbeans 6.5.

Introduction #

This document covers the setup of Netbeans to be used jointly with the Liferay plugin SDK.

It has been tested against Liferay + plugin SDK v5.1.2 and Netbeans 6.5RC1 (but it should be running with any Netbeans version 6+)

Pre-requisites #

  • A running Liferay server (5.1.2)
  • Netbeans 6.5RC1

Plugin SDK #

Introduction #

The plugin SDK is a Liferay tools which allows development of portlets, themes and hooks by facilitating:

  • creation of projects' structure
  • generation of objects (for exemple service layer class for portlets)
  • compilation of projects
  • deployment

All this operation are done thanks to ANT files made available in the SDK.

Installation #

The plugin SDK available on the download page comes with a little bug which breaks portlets folders structure and therefore throws exceptions during deployment. Therefore, a minor correction needs to be done (this issue has been addresses and already fixed. It will be made available in Liferay 5.2.2, see http://support.liferay.com/browse/LPS-152).

A guide gives a very good introduction (including installation) to the plugin SDK and is available here : http://docs.liferay.com/5.0/official/development-documentation5.pdf.

To install the SDK, download and unzip it, update build.${username}.properties file as described in the PDF file. Then, the portlets.zip files, which provide portlets directory skeleton, needs to be changed by a correct one. On a nix/MacOS machine, proceed as follow:

This operation simply replaces the existing portlet.zip file by the one indicated.

Note that the portlet folder structure differs from the one indicated in the PDF file (page 9). The plugin SDK is now ready be to used, a simple portlet will be created to show its usage:

  • cd liferay-plugins-sdk-5.1.2/portlets
  • ./create.sh yop 'yop portlets' (or create.bat on Windows. If created.sh does not run, do a 'chmod +x create.sh' to make executable).

The portlet is now created. To compile and deploy it :

  • cd yop-portlets
  • ant deploy (the "deploy" ant task depends on "compile", so both actions are done)

If you have a running Liferay server, you should see that the portlet has been correctly deployed (check the log file), and it should be available from the portal itself (install it to see). If you update the code (for instante the view.jsp page), you can issue a new 'ant deploy' and reload the webpage to see the update.

Plugin SDK advanced usage #

The plugin SDK comes with advanced tools for generating data model and related Java objects, which make this tool a powerful one. See the doc page 18 (http://docs.liferay.com/5.0/official/development-documentation5.pdf) for more details. If you decide to test it by doing the example, do not forget to import relevant packages in the BookLocalServiceImpl class:

import com.sample.portlet.library.service.base.BookLocalServiceBaseImpl;
import com.sample.portlet.library.model.Book;
import java.util.Date;
import com.liferay.counter.service.CounterLocalServiceUtil;
import com.liferay.portal.service.persistence.UserUtil;
import com.liferay.portal.model.User;

Netbeans #

Netbeans offers portlets development thanks to the portal-pack plugin (http://portalpack.netbeans.org). While being a very nice plugin, it does not generated Liferay specific configuration files : liferay-plugin-package.properties, liferay-portlet.xml and liferay-display.xml (UPDATE: it does now, please see 'update' at the end of this page).

Please note : this document shows a way of using Netbeans and Liferay plugin SDK. Other solution could give same results.

It is recommended to use the portal-pack plugin for the portlet dev but not for the portlet creation: for the creation, the create.sh script file from the plugin SDK. Once the portlet has been created, start Netbeans a create a new project:

  • projet type: Java Web / java application with existing sources
  • select the location of the portlet you created with the plugin SDK.

Netbeans will indicate that a build script exists and will propose to create its own as nbbuild.xml, accept that.

A this point, you have a porlet project with unresolved references to Java objects. From Netbeans, create a new library (tools/Libraries) and include there all Liferay related JAR files.

You can now include tools provided by Netbeans and more specifically by the portal-pack plugin. Go the the project properties page, click 'Frameworks' and there include the "Portlets framework" if you wish.

Final steps:

  • web.xml file must be empty (otherwise Liferay will not accept to deploy the portlet): open the one created and remove everything which stands inside the 'webapp' opening and closing tag;
  • in order to compile and deploy your portlet, the build ANT script provided by the plugin SDK is prefered to the one made available by Netbeans. Go to files, and select 'deploy' in the build.xml file. You can even add a keyboard shortcut (I use F2 for that) for easy compilation/deployment of your portlet.

Note: Netbeans offers to run Tomcat inside the IDE, you can choose to do so or let it run inside a terminal window outside of the IDE.

Conclusion #

This option gives the opportunity to use the power of the two tools.

UPDATE (12/11/2008): a new version of PortalPack plugin for Netbeans has been released and provides new Liferay related features. It might be used to develop portlets without the Liferay plugin SDK. See more at http://portalpack.netbeans.org.

0 Anexos
87634 Visualizações
Média (3 Votos)
A média da avaliação é 3.3333333333333335 estrelas de 5.
Respostas do tópico Autor Data
Great !!!!!!!!!!!!!!!!! Alban KOM. 12 de Novembro de 2008 09:30
very good! Sohui Gu 12 de Novembro de 2008 18:17
The link to the guide is not working... Alberto Gallardo 11 de Outubro de 2010 01:06
The portal pack 3.0.4 is broken liferay 6.0.5... Malek Tarboush 26 de Novembro de 2010 11:09
Link to guide... Aruna Inamdar 12 de Agosto de 2013 12:14
It is recommended to use the portal-pack plugin... Aruna Inamdar 12 de Agosto de 2013 12:41

Great !!!!!!!!!!!!!!!!!
Postado em 12/11/08 09:30.
Postado em 12/11/08 18:17.
The link to the guide is not working (http://docs.liferay.com/5.0/official/development-documentation5.pdf).
Postado em 11/10/10 01:06.
The portal pack 3.0.4 is broken liferay 6.0.5
in case anyone use it
follow the solution steps here

Postado em 26/11/10 11:09.
Link to guide http://docs.liferay.com/5.0/official/development-documentation5.pdf. is not working. Provide valid link. Need details for configuring and developing Liferay portlets using Netbeans IDE and Glassfish server.
Postado em 12/08/13 12:14.
It is recommended to use the portal-pack plugin for the portlet dev but not for the portlet creation: Please let us know the reason behind not to use the portal-pack plugin for portel development in Netbeans. What are the drawbacks, if portal-pack plugin is used for creation purpose
Postado em 12/08/13 12:41.