Bluish Coder

Programming Languages, Martials Arts and Computers. The Weblog of Chris Double.


 

I previously wrote a blog post covering installing the pre-built binary open source release of Zimbra, an open source Email/Groupware product, on an Ubuntu 6.10 machine.

To actually work on the source code, add new functionality, fix bugs and deploy those changes it's easiest to set up an Eclipse based development environment. The process involves installing standard packages for the various Zimbra services (OpenLDAP, MySQL, etc) and using Ant tasks from within Eclipse to handle compilation and deployment.

The steps to do this are fairly well documented in the INSTALL.txt file from the Zimbra subversion repository but I had to make a few changes and find things out based on various forum postings to get it working.

There are still some errors that occur due to what seems to be missing or incorrect files from the subversion repository but what I have got is it working to the point of being able to modify the source and run the new version. I'll update this document as I fix and find better ways of doing things.

I've tested the steps in this article on a Windows XP machine. The instructions will be oriented towards a Windows environment but should also work from a Linux distribution using standard packages. I'll try it out under Linux when I get some spare time. Please note that in most places I've used the forward slash ('/') in pathnames, even for Windows paths. You'll need to use the backslash in paths where appropriate. I'm assuming good knowledge of Windows and/or Linux in this document.

Prequisites

  1. Install the Java Development Kit (JDK) version 1.5.x. Make sure you have the 'bin' directory of this in your path and the JAVA_HOME environment variable set to the install directory.
  2. Install Tomcat version 5.5.x. Install it to the directory 'c:/opt/zimbra/tomcat'. Under linux this would be '/opt/zimbra/tomcat'.
  3. Install MySQL. I use the 'Windows (x86) ZIP/Setup.EXE' version. Use the 'detailed configuration' option of the install so you can set the port that it should run on to be 7306 and the 'root' user password must be 'zimbra'. Install to the directory 'c:/opt/zimbra/mysql'.
  4. Install OpenLDAP. I used version 2.2.28 but later versions should work. Install to the directory 'c:/opt/zimbra/openldap'.
  5. Install Eclipse. I used the 'Eclipse SDK'.
  6. Add the Subclipse plugin for Subversion support under Eclipse. More instructions for using Subclipse are at this IBM DeveloperWorks article.

Subversion

The Zimbra subversion repository is located at the following URL: https://zimbra.svn.sourceforge.net/svnroot/zimbra/trunk

Start Eclipse and open the subversion perspective (Window/Open Perspective/Other/SVN Repository Exploring).

Add the Zimbra SVN repository (right click in the 'SVN Repository' tab, choose 'Add a new...'). The URL to enter is: https://zimbra.svn.sourceforge.net/svnroot/zimbra/trunk

The repository should now be listed and you can browse it if you want.

You'll notice that there are various subdirectories. For example, * Ajax * AnalyzerSample * branches * ThirdParty * ZimbraBuild

Not all of these are needed for the development build we are doing. We will be selecting the specific projects we want. One thing of interest is the 'branches' directory. Listed under that is 'EDISON' and 'FRANK', and under those are what appears to be similar to the top level branches.

From what I understand, the trunk of the SVN repository is the current working copy of the internal version control repository used by Zimbra. It may not always build or work. Under 'EDISON' is the version 4.0 release and 'FRANK' is the current stable release, 4.5.

Checkout Projects

If you want the 'EDISON' build you need to 'checkout' the following projects: * branches/EDISON/Ajax * branches/EDISON/ZimbraServer * branches/EDISON/ZimbraWebClient

If you want the 'FRANK' release you'll need: * branches/FRANK/Ajax * branches/FRANK/ZimbraCommon * branches/FRANK/ZimbraIM * branches/FRANK/ZimbraTagLib * branches/FRANK/ZimbraServer * branches/FRANK/ZimbraWebClient

If you want the 'trunk' release you'll need: * Ajax * ZimbraCommon * ZimbraIM * ZimbraTagLib * ZimbraServer * ZimbraWebClient

To checkout the projects, right click on them, choose 'Checkout...' and if prompted by a dialog box 'Check out as a project in the workspace'. Do this for each one.

Configure Tomcat

Tomcat needs to be configured to have a 'zimbra' user and run on port 7070. To make these changes perform the following copies (Where 'ZimbraServer' is the location in your Eclipse workspace directory for the ZimbraServer project you checked out previously):

copy ZimbraServer/conf/tomcat-5.5/server.xml c:/opt/zimbra/tomcat/conf/
copy ZimbraServer/conf/tomcat-5.5/tomcat-users.xml c:/opt/zimbra/tomcat/conf/

Configure OpenLDAP

Due to the different version (ie. newer version) of OpenLDAP that I installed, changes need to be made to http://svn.sourceforge.net/viewvc/zimbra/trunk/ZimbraServer/conf/ldap/slapd.win.conf?view=markup,ZimbraServer/conf/ldap/slapd.win.conf. In that file replace all occurences of 'c:/opt/zimbra/openldap/etc/schema' with 'c:/opt/zimbra/openldap/schema' except for amavisd.schema and zimbra.schema. In other words, make that section of the file look like this:

include        "/opt/zimbra/openldap/schema/core.schema"
include        "/opt/zimbra/openldap/schema/cosine.schema"
include        "/opt/zimbra/openldap/schema/inetorgperson.schema"
include        "/opt/zimbra/openldap/etc/schema/amavisd.schema"
include        "/opt/zimbra/openldap/etc/schema/zimbra.schema"

Add build files

Now we're ready to start things up. From within Eclipse, with the Java perspective active, open the Ant view (Window/Show View/Ant).

Add the following build files (right click, choose 'Add Buildfiles...'): * ZimbraServer/build.xml * ZimbraWebClient/build.xml

Reset the world

Expand the build file for ZimbraServer. Right click on the 'reset-the-world' option, choose 'Run As' and select 'Ant Build'.

This will run an Ant task that installs schema in OpenLDAP, inserts information into MySQL, and resets the system to a known starting state. It takes a while.

On my system, with the current SVN repository, it fails after doing most of the steps with an error like:

java.io.FileNotFoundException: 
   data/soap/samplecontacts.xml (No such file or directory)

There is a forum posting about this but it is current unanswered. The error seems to be possible to safely ignore. Continue on with the 'deploy' step below.

If it fails due to OpenLDAP not restarting with an error 19, it means you probably didn't make the correct changes to the slapd.win.conf file mentioned earlier. Make those changes and restart the 'reset-the-world'.

'reset-the-world' can always be safely rerun.

Deploy

The next step is to deploy the Zimbra web client. Expand the build file for ZimbraWebClient. Right click on the 'deploy' option, choose 'Run As' and select 'Ant Build'.

This will build the web client files and deploy them to the installed Tomcat instance.

Admin Deploy

The final step is to deploy the admin web tools. Expand the build file for ZimbraWebClient. Right click on the 'admin-deploy' option, choose 'Run As' and select 'Ant Build'.

Test the Installation

To access the running Zimbra web system from the source you just built, use the following URL: http://localhost:7070/zimbra

Login with the user 'user1' and password 'test123'. This should take you to the web mail system.

If you are running the 'trunk' checkout you may get Javascript errors or other issues. If you are running the 'EDISON' or 'FRANK' branches then things should work.

Sending emails

The current setup doesn't allow sending of emails from the webmail interface. The programs required by Zimbra for managing mail are not available on the Windows platform. To work around this you can do the following: 1. Install ActivePerl. 1. Run the following series of commands to install the required libraries:

ppm install Net-LMTP
ppm install SMTP-Server
ppm install Net-DNS
  1. Set the ZIMBRA_HOSTNAME environment variable to the hostname of a running Zimbra installation that will handle the email sending.
  2. Run ZimbraServer/src/perl/zMTAHack.pl

You should now be able to send emails. They will be redirected by zMTAHack.pl to the other running Zimbra installation for delivery.

Tips

When making changes to files in the ZimbraWebClient project you can use the 'dev-sync' and 'admin-dev-sync' Ant tasks from that project to quickly copy the changed files to the already running Zimbra application on Tomcat. This only takes a few seconds compared to having to do a full 'deploy' task.

Links