« Back

Creating Your First EXT Plugin

Company Blogs March 9, 2010 By Edward Shin Staff

Update: Please see the official documentation here:

www.liferay.com/documentation/liferay-portal/6.0/development/-/ai/ext-plugins

The first step that we need to take is to "Check Out" or download the Plugins SDK here:
svn://svn.liferay.com/repos/public/plugins/trunk

You'll have to know how to use an SVN client to check out the latest Plugins SDK, but you'll be able to download it from our website once we release 6.0.

I'll include some screenshots in case you just want a general idea of how it works before it's released.

After checking out the new Plugins SDK, you'll notice that there's a new "ext" directory available:

- We can create a hello-world-ext plugin using the the following command for Unix:
./create.sh hello-world "Hello World"

Or the following command for Windows:
create hello-world "Hello World"

This will create a hello-world-ext plugin which should look like this:

Notice the similarities with the EXT Environment:

- Now let's run an "ant clean":

We get this error message because we haven't defined any of the properties:

app.server.zip.name is the location of the zipped server bundle
ext.work.dir is the location where you want to unzip your server
app.server.dir is the location of your server directory

We'll need these properties so that ant knows the location of the app.server.dir (server directory), the location of the app.server.zip.name (zipped server bundle) and the ext.work.dir (location where you want to unzip your server).

- You can create your own zipped Tomcat bundle by reading my blog post here:
Building a Tomcat Bundle from Liferay trunk

- Once you've created your zipped Tomcat bundle, you can point your "app.server.zip.name" property to it like this:
app.server.zip.name=/Users/ed/liferay/portal/dist/liferay-portal-tomcat-6.0.0.zip

- Create your build.${user.name}.properties file here:

- Set the location of your properties. I've set mine as follows:

 

That's all you need to do to set up the environment!

To recap, all we've done so far is set up 3 properties for the location of our server, the location of our zipped server bundle and the directory that we want to unzip the bundle to.

Now we can see how this works in action:

Running "ant clean" will now delete the server directory and unzip a clean copy of our zipped server bundle:

Running "ant compile" will compile all the necessary ext code.



Running "ant war" will create /plugins/dist/hello-world-ext-5.3.0.1.war

You can hot deploy this war to a running Liferay bundle. It'll tell you to reboot after the ext plugin has been deployed (since you're changing core classes):

After creating your own hello-world-ext plugin, you'll now see how much lighter EXT Plugins is compared to the EXT Environment. Try modifying a few classes to see how it works in practice.

(Keep in mind that EXT plugins are designed to override the portal's core code that cannot be done with hooks, layout templates, portlets, or themes. EXT plugins are not meant to contain new custom services.)

Threaded Replies Author Date
"Keep in mind that EXT plugins are designed to... b v j March 11, 2010 6:44 PM
EXT plugins do support custom services. I've... Edward Shin March 11, 2010 10:19 PM
Is the EXT plugin method to be used only with... Andy Makely March 19, 2010 7:47 AM
EXT plugins are only available in 6.0 so can't... Edward Shin March 19, 2010 1:06 PM
How would i able to make JSON call for the... Gaurav Vijayvergia March 22, 2010 6:56 AM
Hi Edward, Do you have any reference link that... Tarun S. Kayasth April 9, 2010 2:33 PM
Hey Edward, I am starting with Liferay 6.02 so... Ricky Crantz July 12, 2010 2:24 PM
Hi everyone, This post was created on the... Edward Shin July 15, 2010 1:33 PM
based on the comment above about overriding vs... Gary Pinkham August 8, 2010 7:27 AM
Please note that this is NOT supported for the... Michael C. Han April 21, 2010 3:12 PM
We use Enterprise product line, and in 5.2.7.... Csaba Tenkes May 11, 2010 2:59 AM
EXT Plugins will be supported in 6.0 EE. For... Edward Shin May 11, 2010 8:54 AM
Ed, Has the EXT Plugins been tested with... Anonymous May 23, 2010 12:25 PM
I also am having issues with creating a 6.0.2... William Chu June 14, 2010 11:05 PM
Hi Edward: I am new to using Liferay as I find... Luis Cieza Quezada August 17, 2010 8:47 AM
Hi, Thanks for sharing the great details of ext... Rupesh Chotai April 11, 2011 1:46 PM
This is a very useful article. thank you Ed. I... Liferay newbie April 13, 2011 10:57 PM
i try to implement ext plugin as per docs it... himanshu jain January 5, 2012 3:29 AM
[...] Hi Bob, sorry for not making myself... Anonymous March 20, 2012 11:03 PM
Hi, I am new for liferay development.I want to... Amit Shukla June 7, 2012 12:35 AM
[...] I need to overwrite... Anonymous November 6, 2013 11:18 PM

"Keep in mind that EXT plugins are designed to override the portal's core code that cannot be done with hooks, layout templates, portlets, or themes. EXT plugins are not meant to contain new custom services"

If I understand correctly that EXT plugins replace the native 5.x EXT framework, why would they not also support new custom services? For example, we use Service Builder in 5.2 EXT to create new custom services in addition to extending the DB.
Posted on 3/11/10 6:44 PM.
EXT plugins do support custom services. I've tested that this works when I migrated custom services from my 5.2 EXT environment to an EXT plugin.

However, EXT plugins are part of a design shift that we've been making since 4.x. Instead of having monolithic structures, we've slowly been extracting out portlets from core to make it more light weight and customizable, and we've been promoting the use of plugins.

Unlike the EXT environment which is another monolithic structure, EXT plugins are only meant to override core classes.

We realize that people who are migrating from the EXT environment will still need to use custom services in EXT plugins, but new services should be created within portlet plugins and existing services should be migrated to portlet plugins since support for custom services in EXT plugins will eventually be removed.

We realize that this is a big change, but it's a necessary one. If we didn't make these types of changes, things like portlet plugins wouldn't exist which have been very useful for the community as a whole.

We'll continue to support customers that have existing EXT environments as much as we can. Let's continue this discussion on the forums here:
http://www.liferay.com/community/forums/-/message_boards/message/4533829
Posted on 3/11/10 10:19 PM in reply to b v j.
Is the EXT plugin method to be used only with 6.0? Do you recommended that 5.2.3 users continue using the existing EXT environment method?
Posted on 3/19/10 7:47 AM in reply to Ed Shin.
EXT plugins are only available in 6.0 so can't use them for 5.2.
Posted on 3/19/10 1:06 PM in reply to Andy Makely.
How would i able to make JSON call for the plugin environment custom services, if i'm creating outside plugin ext ? I was able to do this in ext environment ? Does this feature still supported ? How to generate code for JSON interface ?
Posted on 3/22/10 6:56 AM in reply to Edward Shin.
Hi Edward,

Do you have any reference link that provides step for changing java files (action file) of an existing functionality. Say if I want to change action file for calendar portlet using ext in plugin.

Thanks,
Tarun
Posted on 4/9/10 2:33 PM in reply to Ed Shin.
Please note that this is NOT supported for the 5.2 product line. This will be supported in the 6.0 product line
Posted on 4/21/10 3:12 PM.
We use Enterprise product line, and in 5.2.7. there IS an ext sdk.
Are you recommended to use it or we need to wait till 6.0. is coming?
Posted on 5/11/10 2:59 AM in reply to Michael C. Han.
EXT Plugins will be supported in 6.0 EE. For 5.x line, it is experimental.
Posted on 5/11/10 8:54 AM in reply to Csaba Tenkes.
Ed,

Has the EXT Plugins been tested with jboss? I am trying to migrate a 5.x ext environment to 6.x ext plugin, so far with no success. I have some more concrete questions, but I don't know if this blog is the proper place.

Regards,
Ken
Posted on 5/23/10 12:25 PM in reply to Edward Shin.
I also am having issues with creating a 6.0.2 ext plugin. I'm getting the following error.

/Users/biuniu/Documents/SVNROOT/liferay-plugins-sdk-6.0.1/ext/build-common­-ext.xml:309: Warning: Could not find file /Users/biuniu/Documents/SVNROOT/ext-work/liferay-portal-6.0.2/jboss-5.1.0/server­/default/deploy/ROOT.war/WEB-INF/web.xml.merged to copy.
Posted on 6/14/10 11:05 PM in reply to .
Hey Edward,

I am starting with Liferay 6.02 so no upgrading issues. When I ran through your example, clean compile and war all worked but when I ran deploy I received the same error as William Chu is the previous post.

I copied the /ROOT/WEB-INF/web.xml to web.xml.merged and the script proceeded until I received:

21:20:24,757 ERROR [PropsUtil:107] Unable to initialize PropsUtil
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:394)
at java.util.Properties.setProperty(Properties.java:143)
at java.lang.System.setProperty(System.java:729)
at com.liferay.util.SystemProperties.set(SystemProperties.java:60)
at com.liferay.portal.util.PropsUtil.<init>(PropsUtil.java:94)
at com.liferay.portal.util.PropsUtil.<clinit>(PropsUtil.java:231)
at com.liferay.portal.util.PropsValues.<clinit>(PropsValues.java:29)
at com.liferay.portal.spring.util.SpringUtil.loadContext(SpringUtil.java:46)
at com.liferay.portal.util.InitUtil.initWithSpring(InitUtil.java:132)
at com.liferay.portal.tools.WebXMLBuilder.main(WebXMLBuilder.java:43)
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.liferay.portal.spring.util.SpringUtil.loadContext(SpringUtil.java:46)
at com.liferay.portal.util.InitUtil.initWithSpring(InitUtil.java:132)
at com.liferay.portal.tools.WebXMLBuilder.main(WebXMLBuilder.java:43)
Caused by: java.lang.NullPointerException
at com.liferay.portal.util.PropsValues.<clinit>(PropsValues.java:865)

Where the missing property is "liferay.home" which I added to properties and now the script is complaining about "portlet.event.distribution":

Loading jar:file:/C:/Liferay/servers/liferay-portal-6.0.2/tomcat-6.0.26/webapps/ROOT/WEB­-INF/lib/portal-impl.jar!/system.properties
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.liferay.portal.spring.util.SpringUtil.loadContext(SpringUtil.java:46)
at com.liferay.portal.util.InitUtil.initWithSpring(InitUtil.java:132)
at com.liferay.portal.tools.WebXMLBuilder.main(WebXMLBuilder.java:43)
Caused by: java.lang.NullPointerException
at com.liferay.portal.util.PropsValues.<clinit>(PropsValues.java:865)
... 3 more

Is there something that I am missing? It seems that there should not be this many snags to deploying a basic ext plugin...

Thanks in advance
Posted on 7/12/10 2:24 PM in reply to Ed Shin.
Hi everyone,

This post was created on the latest revision of trunk back in March. A lot of changes have been made in order to get ready for 6.0 GA, and it looks like the instructions may or may not work as is for all environments. We'll be coming out with new instructions on how to use EXT plugins that won't require as many steps because we'll have everything packaged and downloadable. This post was mainly to pique the interest of anybody that was on the cutting edge, and wanted to check the latest status of EXT plugins at that time. Again, we'll have more streamlined instructions available soon on our wiki or in the documentation section of our website.
Posted on 7/15/10 1:33 PM in reply to Ricky Crantz.
based on the comment above about overriding vs creating new services.. if one wants to create a new Authentication Mechanism.. Is this done via Ext or Hooks?

Thanks!
Gary
Posted on 8/8/10 7:27 AM in reply to Edward Shin.
Hi Edward: I am new to using Liferay as I find it very interesting. I'm investigating, I would modify the sources to add little feature. We have made a modification in the jsp and then as you indicate in your manual we have generated. WAR and we have placed in the "deploy" start the tomcat but the changes are not reflected in the portal. What additional configuration must be performed to be able to see the changes we have made in the EXT (we are using Liferay 6.0)
Posted on 8/17/10 8:47 AM.
Hi,
Thanks for sharing the great details of ext plugin. My team is using Liferay-Jboss bundle 6.0.6.
We have use case for update password portlet. On the update page, user is asked to put the the old password and validation is performed. Once user clicks on "Save" button he/she is redirected to Homepage of the organization and not the community.
Can I use EXT Plugin to develop new custom action class to fullfil this use case?
Posted on 4/11/11 1:46 PM.
This is a very useful article. thank you Ed.
I have a query reg ant clean cmd.
When Im running ant clean cmd:
all it does is delete my example-ext-6.0.5.1.war from the dist folder Is this all that the cmd does? should it not behave the way as mentioned in this article?
again when i run ant war cmd, it re creates the war under dist folder with my changes implemented in the new war.

Please let me know if I'm missing anything and guide me accordingly.

thanks.
Posted on 4/13/11 10:57 PM.
i try to implement ext plugin as per docs it removes all my communities and data....nd remove my portal-properties.ext.?can anyone help me how to revert back my data now?
Posted on 1/5/12 3:29 AM.
[...] Hi Bob, sorry for not making myself clear. It is just a plain servlet filter creation in Liferay. You have to create filter using EXT Plugin. Right now if you see the web.xml of Liferay(path is... [...] Read More
Posted on 3/20/12 11:03 PM.
Hi,

I am new for liferay development.I want to customize document library part .Please help us how I change Document- library -structure.xml and DLFILEentrytypeconstant.java.
Posted on 6/7/12 12:35 AM.
[...] I need to overwrite /util-java/src/com/liferay/util/Normalizer.java I found code on git. I followed this instructions and able to do ant clean I read this Putted my .java file in... [...] Read More
Posted on 11/6/13 11:18 PM.