Development with NetBeans (deprecated)

This guide was first written to explain how to use Liferay package with the Tomcat instance bundled with NetBeans. Unfortunately the auto-deployment required for rapid development did not work in this case. So this guide is left here as a reference how the bundled Tomcat application works, and how to enable Liferay portlet server on that instance.
Please refer to this page for actual working setup.

Install NetBeans with Tomcat

Download the NetBeans Java EE version from NetBeans site. When installing, make sure that the Install Apache Tomcat server option is selected.

Test the installation

Deploy Liferay

Although Tomcat is installed into some system-wide folder, NetBeans creates private profile for each user’s private configuration directory under user’s profile.
Under Linux it is located on ~/.netbeans/[version]/apache-tomcat-[version]_base
In Windows it is something like C:\Users\[username]\.netbeans\[version]\apache-tomcat-[version]_base
All further configuration will be done in that directory.

Install libraries

The default Tomcat installation requires support libraries for Liferay to run properly. These can be extracted from the Liferay Apache Tomcat Bundle.
Extract it, and copy the whole tomcat7/lib/ext directory to the Tomcat configuration directory specified above. Rename the copied ext directory to lib. There is no existing lib directory, but Tomcat instance looks for it and loads the libraries from that path as well.

Install Liferay

Download the WAR file from Liferay download site and copy it into the webapps folder located under private Tomcat configuration directory specified above.

Additional NetBeans Configuration

Enable Tomcat autodeploy

By default Tomcat’s NetBeans instance does not extract and deploy the installed WAR-files. To enable automatic deployment:

 <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">

Expand memory limits

Tomcat will most probably run out of memory when initializing Liferay portal. Therefore the Tomcat instance must be reconfigured to allow bigger memory allocations.

-Xms2048m -Xmx2048m -XX:MaxPermSize=1024m

Testing
Now start the Tomcat server from Services –> Servers by right-clicking on it and choosing Start.
The Tomcat starts, finds the Liferay WAR-file, unpacks it and initializes the environment.

If there are any out of memory errors, then update the VM Options field to allow even bigger allocations.

Finish Liferay setup

Since Liferay portal is located directly under Tomcat’s web root, the Liferay context must be fixed so that the generated URLs will have correct prefix.
This can be easily verified by the visual UI from the previous step. If Liferay setup screen looks ugly, it means the context is wrong.
It can be updated by creating the following file webapps/liferay/WEB-INF/classes/portal-ext.properties:

portal.ctx=/liferay

As a reminder the webapps directory is located under .netbeans/[version]/apache-tomcat-[version]_base under current user profile.
Note: Please don’t delete the WAR file or Tomcat will undeploy and delete the Liferay component from webapps directory. To delete the archive, first turn autodeploy off again. If the Liferay is redeployed, the portal-ext.properties file must be regenerated manually again.
Now restart the Tomcat and the Liferay context should be fixed and Liferay setup screen look fine.