When deploying custom portlets, you'll sometimes encounter errors that are hard to track down. If the portlet is not configured correctly, debuggers may not reach ANY of your custom code, as a problem may cause a rendering issue upstream.
Debugging (Request flow) #
There are some key areas of Liferay code you can place breakpoints or other logging code to see what is going on in your code. This describes the flow of a browser request thru the Liferay code from request of the page, all the way down to rendering an individual portlet:
- The initial request comes into the portal server from the browser, and hits the service() method of the class com.liferay.portal.servlet.MainServlet. Here, a variety of objects are created and added to the request for use by code downstream (such as company Id, user objects, etc.)
- Code passes through the servicePre() method of the class com.liferay.portal.events.ServicePreAction. Here is where the ThemeDisplay object is created and populated for downstream code use.
- The theme infrastucture code will call into the class com.liferay.taglib.util.ThemeUtil to render the content of a theme. It will call either the mehod includeJSP() to include JSP rendered content, or includeVM() to include Velocity rendered content.
- When using a Velocity based theme, the request will flow thru the class com.liferay.portal.velocity.VelocityVariables and the method insertVariables(). That method is where various Velocity variables for use by the theme system is added to the Velocity context.
- For each column in the page's layout, the PortletColumnLogic class processes each portlet using the processContent() method. In this method, the HTML that surrounds every portlet is generated. Further processing is then delegated to the RuntimePortletUtil via the processPortlet() method. Then on to the actual rendering...
- An individual portlet is rendered by the render_portlet.jsp code located (in Tomcat) in the webapps/ROOT/html/portal directory. This JSP is called to render each portlet on the page. Debug code can be added to this file to see exactly what is going on just before and just after the code in your custom portlet is executed.
- As will be found by looking through the JSP code, render_portlet.jsp uses InvokerPortletImpl's render() method to render portlets. The primary function of this method is to check if a portlet's expiration-cache has been set or has expired. If the expiration-cache has been set, InvokerPortletImpl then checks whether the portlet's most recently cached content is fresh enough to use.