« Back to Development

Fast Plugin Development

Save time by allowing developers to work with exploded plugin WARs instead of having to package them for deployment.

Create a context file #

The first thing to do is create a context file for the plugin, pointing to the exploded WAR: Create an xml file called like your plugin. For example, if your plugin is a portlet called something-portlet your file must be called something-portlet.xml and the content will be the following:


Deploy context file #

Once created just drop this file into the Liferay autodeploy directory. Liferay will copy this file to TOMCAT_DIR/conf/Catalina/localhost and the plugins will be registered. If the WAR was previously deployed, a new copy of the context file to the autodeploy directory will cause a redeploy of the exploded WAR. (If you had deployed your plugin before, it is advised to remove the old deployed application in webapps folder and restart Tomcat).

Copy dependencies #

You may probably need some libraries and tlds that were previously copied from the core. In order to know which ones you need, go to the webapps/somthing-portlet/WEB-INF folder and copy the lib and tld folders to your plugin WEB-INF folder too.

Using Fast Development in Tomcat #

From now on, if you change jsp files, they are modified when you refresh the page in your browser. For java classes and xml files you need to do ant compile from the plugin folder and copy again the context file into the Liferay autodeploy directory unless the Tomcat's context property "reloadable" is set to true. To do so, open the $TOMCAT_LIFERAY/conf/context.xml file and replace the line <Context> by <Context reloadable="true">. Then restart Tomcat. You can now update any part of the webapp (JSP, JSF pages... Java beans, servlets.... and they will automatically be reloaded by the Tomcat class loader).

Automating the configuration for fast development #

The steps outlined in the previous sections are valid for one portlet. If you are working with many portlets you may want to automate it so that the configuration is easily applied to any new portlet.

The following subsections explain how to achieve this by customizing the build scripts of the Plugins SDK

1) Extend the 'create' target #

Add the following quoted with EXPLODEDWARTEMPLATE inside the create target in the pluginsSDK\portlets\build.xml file:

	<replace dir="${portlet.name}-portlet">
		<replacefilter token="@portlet.name@" value="${portlet.name}" />
		<replacefilter token="@portlet.display.name@" value="${portlet.display.name}" />
		<antelope:stringutil string="${basedir}" property="pluginpath">
			<antelope:replace regex="\\" replacement="/" />
		<property name="plugincontextfile" value="${pluginpath}/${portlet.name}-portlet/${portlet.name}-portlet.xml" />
		<copy file="${pluginpath}/EXPLODEDWARTEMPLATE-portlet.xml" tofile="${plugincontextfile}" />
		<replace file="${plugincontextfile}">
			<replacefilter token="@portlet.name@" value="${portlet.name}" />
			<replacefilter token="@pluginpath@" value="${pluginpath}" />
	<mkdir dir="${portlet.name}-portlet/docroot/WEB-INF/tld" />

2) Create a template Tomcat configuration file #

Create a file named EXPLODEDWARTEMPLATE-portlet.xml inside the pluginsSDK\portlets directory with the following content:

	<?xml version="1.0"?>

3) Done #

Now you can run ant create for creating new portlets as usual and they will be created with 'fast development' preconfigured.

Other useful customizations #

Deployment of exploded WAR using ANT #

Add the following new target inside the pluginsSDK\portlets\build-common-portlet.xml file:

	<target name="deploy-exploded" depends="compile">
			<antelope:stringutil string="${basedir}/${plugin.name}.xml" property="plugincontextfile">
				<antelope:replace regex="\\" replacement="/" />
			<copy file="${plugincontextfile}" todir="${auto.deploy.dir}" />

Note that you also have to add the antelope prefix:


Now, you could do a deploy of the exploded WAR using: ant deploy-exploded

1 Attachment
Average (0 Votes)
The average rating is 0.0 stars out of 5.
Threaded Replies Author Date
Thanks for the tip. However, it does not run... Fabrice Clari December 5, 2008 12:45 AM
I've changed portal property:... Mariusz Nosiński March 11, 2009 7:56 AM
It is nice. It did run correctly on my side... Jonas Yuan February 24, 2009 1:58 PM
Yes. This task could be normally handled by... Jonas Yuan February 24, 2009 2:35 PM
I must be doing something wrong, I can't get... Seth Wallace December 1, 2009 1:50 AM
For the docBase parameter, I specified Tomcat's... Mike Harris April 1, 2011 1:24 PM
I need help for Jboss Fast... venkatesan shanmugasundaram October 29, 2014 12:37 PM

Thanks for the tip.
However, it does not run correctly on my side when copying context file to Liferay hot deploy directory, but it works when copying that file directly to $TOMCAT_LIFERAY/conf/localhost/Catalina.

I have opened a ticket since it is not the normal behaviour: http://issues.liferay.com/browse/LPS-883.

Posted on 12/5/08 12:45 AM.
It is nice. It did run correctly on my side when copying context file to Liferay hot deploy directory - at revision 26723.


Jonas Yuan
Posted on 2/24/09 1:58 PM.
Yes. This task could be normally handled by the Liferay hot deploy process: adding Ant target deploy-exploded in Plugins SDK - build-common-plugin.xml.

Add following lines in build-common-plugin.xml

// after <property name="plugin.file" value="${project.dir}/dist/${plugin.name}-${lp.version}.${plugin.version}.war" />

<property name="context.file" value="${project.dir}/portlets/${plugin.name}/${plugin.name}.xml" />

// after <target name="deploy" depends="war">
// <copy file="${plugin.file}" todir="${auto.deploy.dir}" />
// </target>

<target name="deploy-exploded" depends="compile">
<copy file="${context.file}" todir="${auto.deploy.dir}" />

Posted on 2/24/09 2:35 PM in reply to Jonas Yuan.
I've changed portal property: 'auto.deploy.tomcat.conf.dir=../conf/Catalina/localhost' to 'auto.deploy.tomcat.conf.dir=${catalina.base}/conf/Catalina/localhost', and portlets deploys correcty when context file is copied to autodeploy dir.
Posted on 3/11/09 7:56 AM in reply to Fabrice Clari.
I must be doing something wrong, I can't get this to work with 5.2.3. Tomcat is correctly picking up my Context.xml file and trying to load the docroot I pointed to, but it's complaining about ClassNotFoundExceptions for com.liferay.portlet.StrutsPortlet.

I copied over the dependencies from the original, normal deployed tomcat\webapps\myPortlet directory as mentioned (TLD and LIB folders). Is the jar containing StrutsPortlet somewhere else?
Posted on 12/1/09 1:50 AM.
For the docBase parameter, I specified Tomcat's webapp folder of my project and it worked fine.
Posted on 4/1/11 1:24 PM in reply to Seth J Wingert.
I need help for Jboss Fast developments(Hooks,Portlets,Ext... )
Please some one help on this..
Posted on 10/29/14 12:37 PM.