Building a Tomcat Bundle from Liferay trunk

Update October 6, 2010: Now that we've officially packaged the bundles for Liferay 6 in both our CE and EE releases, you can now download the bundles from liferay.com instead of building them from scratch. This blog was based on an ongoing revision of trunk so some of the steps will be outdated at this time.

If you've ever wondered which Tomcat bundle to use when deploying Liferay trunk, you can actually build your own using build-dist.xml. This step is the first one needed to check out the new Plugins EXT environment.

In the past, I used to download the latest version of our Tomcat bundle from our website, but using build-dist.xml is easier and requires less steps. Once Liferay 6.0 is released, you'll be able to download the bundle directly from our website.

You can download trunk here using an svn client:
svn://svn.liferay.com/repos/public/portal/trunk

From the Liferay trunk directory, you can run:
ant all

And then:
ant -buildfile build-dist.xml zip-tomcat

Assuming that you checked out Liferay trunk to the following directory:

Running the commands will look something like this:

 

ブログ
I notice when I create a tomcat bundle, it is missing many files (such as the tomcat startup scripts) that are found in a normal tomcat install, and in the zipped tomcat bundle. I am able to get these files from a different tomcat install, but I'm wondering why they are missing, or what process you use to add them to your bundle?
Unfortunately, I don't have time to check this, but I think that's all I needed to do. The startup scripts were there, and I didn't need to do any additional work to include them. You might want to take a look at build-dist.xml to see if any changes were made.
the first step "ant all" does not work either:
D:\Projekte\xy\workspace\Liferay_Portal\build.xml:650: D:\Projekte\xy\liferay\liferay-portal-6.0.0\tomcat-6.0.24\conf\catalina.properties doesn't exist
The only four things which are important:
- you need to checkout liferay portal/trunk to create a java project in eclipse
- you need a clean tomcat installation (remember its folder)
- create the file app.server.[hostname].properties in your project root directory as a copy from app.server.[hostname].properties and modify app.server.zip.name, app.server.parent.dir and app.server.tomcat.dir to the tomcat folder
- run ant all (calls clean,start,deploy)
- additionaly you can run ant -buildfile build-dist.xml zip-tomcat to create a zip in [projectfolder]/dist

Thats all :-)
Hi Mathias,

A few clarifications:
I updated to revision 49446, and "ant all" runs successfully. I don't have any custom properties so this probably doesn't work for you because you have custom settings in your app.server.properties file.

The steps you listed are more of how to deploy to a server vs. building a Liferay Tomcat bundle although after looking at the build script, the steps are pretty similar.
I just downloaded trunk and got the same error about catalina.properties not found. I am fairly sure that the build worked, but since i did not have a well configured app.server.properties it could not find the tomcat to deploy stuff to. It doesn't seem like a show stopper if one understands what's going on.

After i ran the target to create the tomcat bundle i unzipped it and configured app.server propperly... I'm running ant all again to see what happens.

Thanks!
Hi Jonathan,

I just updated to revision 49446 (the latest revision as of right now), and the build script is downloading Tomcat directly from Apache's website. The startup scripts are definitely included in the download. You can go through the build script (build-dist.xml) to see why build scripts aren't being created for you.

I'll give you the high level to help you get started. The first thing that it does is call unzip-tomcat, and if you look inside the unzip-tomcat target, you'll see that it downloads Tomcat from the following location:

app.server.tomcat.zip.url=http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.24/bin/${app.server.tomcat.zip.name}

where ${app.server.tomcat.zip.name} = apache-tomcat-6.0.24.zip

http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.24/bin/apache-tomcat-6.0.24.zip

If you download Tomcat from that URL, you'll see that the startup scripts are there. Start from there, and see at what point your startup scripts aren't being included.
This may be topic for a forum thread instead. zip-tomcat does not call unzip-tomcat in the build-dist.xml i just got from trunk. It simply deletes the old one and zips up a new one using app.server.tomcat.dir.

I also have no custom properties file...

I'll post the combination that worked for me as a new comment for cleanness.
The combination of ant calls that worked for me are:

ant clean start
ant -buildfile build-dist.xml build-dist-tomcat

After that *ant all* calls work because now there is good tomcat to deploy to. (downloaded by unzip-tomcat called by build-dist-tomcat).

After that *ant zip-tomcat* should also work. While it was not failing with the given instructions, it was creating a zip that contained no tomcat stuff, just liferay stuff...

build-dist-tomcat looked like a good target, but there are other ant calls that will eventually produce the same thing.
Hi!

It worked for me with your instructions, without that two previous ant calls it was giving a compile error (no catalina.properties found). Thanks to both, Alex and Edward!

Greets.
hi Edward,

i had followed your steps for building liferay from trunk,
have downloaded source from

svn://svn.liferay.com/repos/public/portal/trunk

executed the steps you have said, every thing went well, i have got the distribution file. i have able to start tomcat successfully with out any error. when i tried to login using test@liferay.com and test as password, it is showing blank screen. on tomcat console it is throwing an error

10:37:15,484 ERROR [velocity:151] Exception rendering #parse(_SERVLET_CONTEXT_/html/themes/_unstyled/templates/init.vm) at _SERVLET_CONTEXT_/html/themes/classic/templates/portal_normal.vm[line 3, column 1]
10:37:15,531 ERROR [IncludeTag:329] Current URL / generates exception: Invocation of method 'hasMyPlaces' in class com.liferay.portal.model.impl.UserImpl threw exception com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.QueryException: Expected positional parameter count: 24, actual parameters: [2, 1, null, null, null, null, null, 2, 1, null, null, null, null, null, 2, 1, null, null, null, null, null] [( SELECT Group_.groupId AS groupId, Group_.name AS groupName, Group_.type_ AS groupType, Group_.friendlyURL AS groupFriendlyURL FROM Group_ INNER JOIN Users_Groups ON (Users_Groups.groupId = Group_.groupId) WHERE (Group_.liveGroupId = 0) AND (Users_Groups.userId = ?) AND (Group_.companyId = ?) AND (Group_.classNameId
= ?) AND (Group_.liveGroupId = 0) AND (Group_.name != 'Control Panel') AND (lower(Group_.name) LIKE ? OR lower(Group_.name) LIKE ? OR ? IS NULL) AND (lower(Group_.description) LIKE ? OR ? IS NULL) AND (Group_.type_ != 4) ) UNION ( SELECT Group_.groupId AS groupId, Group_.name AS groupName, Group_.type_ AS groupType, Group_.friendlyURL AS groupFriendlyURL FROM Group_ INNER JOIN Groups_Orgs ON (Groups_Orgs.groupId = Group_.groupId) INNER JOIN Users_Orgs ON (Users_Orgs.organizationId = Groups_Orgs.organizationId) WHERE (Group_.liveGroupId = 0) AND (Users_Orgs.userId = ?) AND (Group_.companyId = ?) AND (Group_.classNameId = ?) AND (Group_.liveGroupId = 0) AND (Group_.name != 'Control Panel') AND (lower(Group_.name) LIKE ? OR lower(Group_.name) LIKE ? OR ? IS NULL) AND (lower(Group_.
description) LIKE ? OR ? IS NULL) AND (Group_.type_ != 4) ) UNION ( SELECT Group_.groupId AS groupId, Group_.name AS groupName, Group_.type_ AS groupType, Group_.friendlyURL AS groupFriendlyURL FROM Group_ INNER JOIN Groups_UserGroups ON (Groups_UserGroups.groupId = Group_.groupId) INNER JOIN Users_UserGroups ON (Users_UserGroups.userGroupId = Groups_UserGroups.userGroupId) WHERE (Group_.liveGroupId = 0) AND (Users_UserGroups.userId = ?) AND (Group_.companyId = ?) AND (Group_.classNameId = ?) AND (Group_.liveGroupId = 0) AND (Group_.name != 'Control Panel') AND (lower(Group_.name) LIKE ? OR lower(Group_.name) LIKE ? OR ? IS NULL) AND (lower(Group_.description) LIKE ? OR ? IS NULL) AND (Group_.type_ != 4) ) ORDER BY groupName ASC] at _SERVLET_CONTEXT_/html/themes/_unstyled/temp
lates/init.vm[line 278, column 31]
10:37:15,546 ERROR [IncludeTag:154] org.hibernate.QueryException: Expected positional parameter count: 24, actual parameters: [2, 1, null, null, null, null, null, 2, 1, null, null, null, null, null, 2, 1, null, null, null, null, null] [( SELECT Group_.groupId AS groupId, Group_.name AS groupName, Group_.type_ AS groupType, Group_.friendlyURL AS groupFriendlyURL FROM Group_ INNER JOIN Users_Groups ON (Users_Groups.groupId = Group_.groupId) WHERE (Group_.liveGroupId = 0) AND (Users_Groups.userId = ?) AND (Group_.companyId = ?) AND (Group_.classNameId = ?) AND (Group_.liveGroupId = 0) AND (Group_.name != 'Control Panel') AND (lower(Group_.name) LIKE ? OR lower(Group_.name) LIKE ? OR ? IS NULL) AND (lower(Group_.description) LIKE ? OR ? IS NULL) AND (Group_.type_ != 4) ) UNION ( SE
LECT Group_.groupId AS groupId, Group_.name AS groupName, Group_.type_ AS groupType, Group_.friendlyURL AS groupFriendlyURL FROM Group_ INNER JOIN Groups_Orgs ON (Groups_Orgs.groupId = Group_.groupId) INNER JOIN Users_Orgs ON (Users_Orgs.organizationId = Groups_Orgs.organizationId) WHERE (Group_.liveGroupId = 0) AND (Users_Orgs.userId = ?) AND (Group_.companyId = ?) AND (Group_.classNameId = ?) AND (Group_.liveGroupId = 0) AND (Group_.name != 'Control Panel') AND (lower(Group_.name) LIKE ? OR lower(Group_.name) LIKE ? OR ? IS NULL) AND (lower(Group_.description) LIKE ? OR ? IS NULL) AND (Group_.type_ != 4) ) UNION ( SELECT Group_.groupId AS groupId, Group_.name AS groupName, Group_.type_ AS groupType, Group_.friendlyURL AS groupFriendlyURL FROM Group_ INNER JOIN Groups_UserGro
ups ON (Groups_UserGroups.groupId = Group_.groupId) INNER JOIN Users_UserGroups ON (Users_UserGroups.userGroupId = Groups_UserGroups.userGroupId) WHERE (Group_.liveGroupId = 0) AND (Users_UserGroups.userId = ?) AND (Group_.companyId = ?) AND (Group_.classNameId = ?) AND (Group_.liveGroupId = 0) AND (Group_.name != 'Control Panel') AND (lower(Group_.name) LIKE ? OR lower(Group_.name) LIKE ? OR ? IS NULL) AND (lower(Group_.description) LIKE ? OR ? IS NULL) AND (Group_.type_ != 4) ) ORDER BY groupName ASC]
at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:367)
at org.hibernate.impl.SQLQueryImpl.verifyParameters(SQLQueryImpl.java:209)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:150)
at com.liferay.portal.dao.orm.hibernate.SQLQueryImpl.list(SQLQueryImpl.java:86)
at com.liferay.portal.kernel.dao.orm.QueryUtil.list(QueryUtil.java:67)
at com.liferay.portal.kernel.dao.orm.QueryUtil.list(QueryUtil.java:52)
at com.liferay.portal.kernel.dao.orm.QueryUtil.iterate(QueryUtil.java:46)
at com.liferay.portal.kernel.dao.orm.QueryUtil.iterate(QueryUtil.java:39)
at com.liferay.portal.service.persistence.GroupFinderImpl.findByC_N_D(GroupFinderImpl.java:484)
at com.liferay.portal.service.impl.GroupLocalServiceImpl.search(GroupLocalServiceImpl.java:808)
at com.liferay.portal.service.impl.GroupLocalServiceImpl.search(GroupLocalServiceImpl.java:793)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:86)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.service.GroupLocalServiceUtil.search(GroupLocalServiceUtil.java:464)
at com.liferay.portal.model.impl.UserImpl.getMyPlaces(UserImpl.java:306)
at com.liferay.portal.model.impl.UserImpl.getMyPlaces(UserImpl.java:259)
at com.liferay.portal.model.impl.UserImpl.hasMyPlaces(UserImpl.java:578)


need help, thank you