Remote Debugging Liferay in NetBeans 8

Currently, Liferay has excellent Eclipse support with the Liferay IDE and Liferay Developer Studio. However, as of this writing, Liferay has no official NetBeans plugins or IDE. So what are you to do if you want to develop on Liferay in NetBeans? Well you can run Liferay from the terminal of course, but what if you want to debug your code or Liferay's code or both? Remote debugging is the solution. Here's how you can do it with NetBeans:

  1. Load up the source code for your project and (optionally) the source code for Liferay Portal in Netbeans.
  2. Compile your project in debug mode.
  3. Set your breakpoints.
  4. In the terminal go into Tomcat's bin/ directory:
    $ cd $LIFERAY_HOME/tomcat-${version}/bin
  5. Execute the following command to start up Tomcat in debug mode:
    $ ./catalina.sh jpda start
  6. Once the portal has started, deploy your project to Liferay.
  7. In NetBeans attach a debugger to the running Tomcat by selecting Debug -> Attach Debugger... from the menu bar.
  8. In the Attach Debugger... dialog (assuming that you are using the default Tomcat settings) set the port to 8000 and click OK.

After that, the NetBeans debugger should connect to the running Tomcat and allow you to debug Liferay.

Thanks to Alex Wallace for his forum post explaining how to do this.