Development with NetBeans
Portlet development needs the following software installed:
- NetBeans IDE (obviously). The bundled Tomcat instance is not necessary since we must use the Liferay all-in-on package.
- Liferay all-in-one package with Tomcat included.
- NetBeans Portal Pack plugin for portlet development.
Install NetBeans
Download the NetBeans Java EE version from NetBeans site. The Install Apache Tomcat server option is not necessary to be selected but nevertheless it might be a good idea to have a plain Tomcat installation on the system.
Install Liferay Package
Get the Liferay Tomcat bundle from their download page. Extract it and place somewhere. The directory must be writable to the developer user.
Install Portal Pack Plugin
Although portlets can be developed without this plugin, it is much easier to configure the Liferay server and automatic deployment for rapid testing. This means the actual package can be injected into Liferay portal when modifications are saved. No need to upload the WAR-files nor load something manually.
- Get the plugin from the Portal Pack site.
- Read the installation instructions how to correctly install the plugin!
- If you get error “The plugin org.netbeans.libs.commons_logging is requested …” it means that the NetBeans installation currently does not have the required class available anymore. It’s a bug and hopefully will be fixed soon. The only workaround currently is to install additional pluginthat provides the required package.So, get the plugin and add to the installed plugins list (like the Portal Pack installation guide described). The dependency requirement will be fixed and the installation is performed.
Configure NetBeans
- Start NetBeans and choose Services –> Servers.
- If NetBeans asks for a master password, enter or create it.
- Right-click on Servers and choose Add Server
- Select Liferay Portal Server 5.1.x/5.2.x/6.x and click Next
- For the Server Type select Tomcat 6. It works regardless the fact that the actual Tomcat instance is version 7.
- For Catalina Home point to the Tomcat directory inside the Liferay bundle. The path must end with something like liferay-portal-6.1.0-ce-ga1\tomcat-7.0.23.
- All other fields should be filled automatically and the error Not a valid catalina base dir should disappear.
- Click Next. There is nothing to change in that dialog right now. The Auto Deploy Dir is grayed out and cannot be enabled yet. So click Finish.
Test the Setup
The new server should appear in the server list. Right-click on it and choose Start. The initialization takes some time but when it is finished it should display the Liferay initial setup page on http://localhost:8080. Since this is dedicated server, Liferay is located in the root directory and no context path is required.
Configure automatic deployment
- Choose Services –> Servers.
- Right-click on Liferay server and choose Properties.
- Select Directory Deployment Enabled and point Auto Deploy Dir to the directory named deploy in the Liferay bundle. The path must end with something like liferay-portal-6.1.0-ce-ga1\deploy
- Close the dialog and restart the server by right-clicking on it and choosing Restart.
Using the Configured Server
To deploy a portlet project to the newly configured server, right-click on project root and choose Properties. From the left-hand pane select Run. From the drop-down list on the right side choose the Liferay server.
Now, when running the project, the portlet should be automatically deployed and available in Liferay’s portlet menu. When the portlet is added to some webpage, it is automatically updated when redeploying.