
Develop Liferay Core with Tomcat
Table of Contents [-]
Save time by allowing developers to deploy with directories instead of always copying files on Tomcat. Orion and Oracle 10 has great ways for this and has traditionally been used by Liferay developers to save time. Now we've ported the same concept to Tomcat.
Setup #
A few steps are needed. In the following steps it is assumed that you have checked out the sources of Liferay Portal to:
D:/Projects/liferay/portal/trunk
Change that to whatever directory you are using either on Windows or Linux.
1) Modify tomcat/conf/web.xml #
By default, Tomcat checks modified JSPs every 4 seconds, let's truncate that to 0 seconds. Add these two init-params to the JspServlet.
<servlet> <servlet-name>jsp</servlet-name> <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class> <init-param> <param-name>modificationTestInterval</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>development</param-name> <param-value>true</param-value> </init-param>
2) Setup context file load order #
Tomcat does not have a guaranteed load order for web apps. We wrote a custom HostConfig to ensure that context files are always loaded alphabetically (case sensitive).
Modify tomcat/conf/server.xml, add the custom hostConfigClass
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false" hostConfigClass="com.liferay.support.tomcat.startup.PortalHostConfig">
3) Run "ant clean" #
To make sure that your current Tomcat doesn't contain the portal deployed.
4) Modify tomcat/conf/Catalina/localhost/ROOT.xml #
<Context path="" crossContext="true" docBase="D:/Projects/liferay/portal/trunk/portal-web/docroot" > ...
5) Modify your app.server.${username}.properties #
Set
app.server.tomcat.portal.dir=D:/Projects/liferay/portal/trunk/portal-web/docroot
The property "app.server.tomcat.dir" must remain pointing to your Tomcat folder, as usual.
6) Run "ant all" from the source #
Be sure to stop the tomcat instance and then run:
ant all
Note: it has been reported that if this command is executed while tomcat is running the file ROOT.xml is mistakenly deleted by Tomcat and has to be recovered manually.
7) Cleaning #
Delete unnecessary webapps in tomcat/webapps/cms-web , laszlo-web, tunnel-web, etc (unless you're doing work on laszlo related portlets, tunneling, etc).
8) Fixing Paths #
If you are using Plugins SDK remember to change the build.username.properties :
app.server.lib.portal.dir= .../portal-web/docroot/WEB-INF/lib app.server.portal.dir= .../portal-web/docroot
Usage #
From now on, modifying and testing the changes in Liferay's source code is a lot faster. Following are a description of the steps necessary for some common changes:
Change a JSP or velocity file #
- Make the change
- Hit refresh in the browser
Change a class in portal-impl, portal-kernel or portal-service #
- Make the change
- Stop tomcat
- Execute from portal-impl 'ant compile-fast'
- Start tomcat
- Hit refresh in the browser
Change a WEB-INF/*.xml file #
- Make the change
- Stop tomcat
- Execute 'ant build-website'
- Start tomcat
- Hit refresh in the browser
Changes in other modules #
- Stop tomcat
- Run ant deploy from within each of the modified modules
- Start tomcat
Other changes #
If you've made changes elsewhere or you've made changes to a lot of places:
- Stop tomcat
- Run ant deploy from the root directory
- Start tomcat
Final notes #
Be aware that with these settings your classes are now built to D:/Projects/liferay/portal/trunk/portal-web/docroot/WEB-INF/classes instead of portal-impl/classes.