Chapter 2. Keel Installation

This chapter shows how to install Keel and setup a user project to develop applications using Keel. This chapter concentrates on using Ant to setup the project. The instructions in this chapter should be followed whether or not an IDE is used.

If you are an expert, or you are just impatient, a quick set of instructions can be found in Section 2.4, “Quick Summary for the Expert/Impatient”.

2.1. Pre-requisite Environment

Keel needs a minimal Java environment setup prior to use.

2.1.1. Java Development Kit (JDK)

A Java development environment is, of course, needed. Keel required use of J2SE v1.4 or later Java Development Kit (JDK), probably best to use the latest JDK-1.4.2. JDKs are available from . Keel does not explicitly require it, but for good measure you should verify that the JAVA_HOME environment variable is set properly for your system. The Java bin directory should ($JAVA_HOME/bin in Unix, %JAVA_HOME%\bin under Windows) should be in your OS path ($PATH for UNIX, %PATH% for Windows). If your environment is setup correctly, then the following should be typical output:

$ java -version
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)

2.1.2. Jakarta Ant

Keel's build system is based on the Jakarta Ant subsystem available at . Keel requires use of Ant-1.6.1 or later, earlier versions of Ant will absolutely not work due to Keel's use of the new "<import>" and "<macrodef>" tags in Ant 1.6. Like Java, Ant required definition of the ANT_HOME environment variable, as well of addition of Ant's bin directory in the OS path. In this case, Keel also requires the ANT_HOME variable be set, since Keel isnatlls two optional JARs in Ant's lib directory (bsf.jar and js.jar, so that the Ant "<script>" tag works). If Ant is installed properly on your system, the following should be typical output:

$ ant -version
Apache Ant version 1.6.1 compiled on February 12 2004

2.1.3. Keel Distribution

Starting with Keel-2.1 early-access (EA) and release-candidate (RC) releases, Keel distributions are available in two forms, binary and source. Other than the fact that the source is not included in the binary distributions, the packagaing and installation mechanisms are identical for both. In either case, Keel is available from as a zipped archive. The primary installation of Keel consists simply of unarchiving the .zip file into some localdirectory of the user's choice. The directory where Keel is unarchived should be defined using an environment variable called KEEL_HOME (iaccessible as $KEEL_HOME on Unix, %KEEL_HOME% on Windows).

2.2. Keel User Project

Following instructions in the previous sections, we should now have all the prerequisites for creating a Keel project in place. To recap, we have installed Java, Ant, and the Keel distributions. The three respective environment variables should be JAVA_HOME, ANT_HOME and KEEL_HOME.

2.2.1. Creating a New Project

To create a starter project, type the following in an Unix environment:

cd $KEEL_HOME/keel-build
ant 

Similarly, in a Windows (DOS) Command Prompt, type:

cd %KEEL_HOME%\keel-build
ant

When prompted for a project directory enter a fully qualified directory name of where you want your project to be created. When pronpted for a short name for the project, enter that as well. Keel will create the directory for you, and place an Ant build.xml, ant.properties and user-modules.xml files in there. We will refer to the project directory just created using the KEEL_PROJ environment variable (it is not a must that you define this, but it makes it simpler to refer to the project directory).

The personality of the Keel internals you are using (the client layer, the comm layer, available services, etc.) are all defined by properties in the ant.properties file. By default, you get a system that uses Struts as the client layer, Keel's internal comm. layer that allows the Keel client and server sides to be embedded within the same webapp/Java VM, and Hypersonic/HSqlDB as the underlying RDMS for the persistence layer. The webapp deployment is done using Tomcat-5.0.x. For the first time installation, it is recommended that you stick with this configuration to verify that everything is working correctly.

Should you later choose to change the configuration, you can navigate to $KEEL_HOME/keel-build/example-projects and copy one of the several ant.properties files into your project. Be sure to run "ant clean" before using your new configuration.

2.2.2. Initial Install and Build

The very first time you use a particular set of deployment properties (ant.properties in $KEEL_PROJ), certain 3rd-party tools that are needed to succesfully build and deploy to the chosen environment need to be made available to Keel. It is not really necessary to have Keel download and install these tools (like Jakarta Struts, Jakarta Tomcat, etc.) if you already have them, since you could provide the paths to these tools in ant.properties. However, for the sake of simplicity and to make sure that we can quickly get Keel up and running, we'll let Keel download and install these tools. To do this, as well as the initial build explained in the section immediately followinbg this, simply type:

cd $KEEL_PROJ
ant completeinstall

The completeinstall target assumes that you have network access. If you are in a firewalled netwrok and access the Internet through a Proxy, then you might try setting "remote.useproxy=true" and "remote.proxy=nn.nn.nn.nn" in $KEEL_PROJ/ant.properties before trying to run "ant completeinstall". If you are unable to have network access, somehow acquire the 3rd-party distributions (see $KEEL_DIST/keel-build/ant.properties for the exact versions) and place them in $KEEL_HOME/keel-build/deploy. Then run:

cd $KEEL_PROJ
ant nonetinstall

2.2.3. Initial Build For Changed Deployments

If you ran "completeinstall" or "nonetinstall" from above, you can skip this section since it is an included part of those targets. If you go back and change deployments radically such that you need new 3rd party tools (for instance, use Cocoon instead of Struts), you must go back and rerun "ant completeinstall". If, however, you change your deployment properties to include or delete Keel apps and/or services you need to regenerate you Keel configuration. To do this, do:

cd $KEEL_PROJ
ant clean
ant build-all

This step will create a conf directory in $KEEL_PROJ, that contains the Keel client and server-side configuration files, a webapp directory that contains the Keel client side. Depeding on the setting of the keel.server.path property in ant.properties, the Keel server-side will typically either be embedded in $KEEL_PROJ/webapp/WEB-INF/keel or in $KEEL_PROJ/server.

2.2.4. Unit Tests

Once the build is complete, you can run Keel unit tests using the following command:

cd $KEEL_PROJ
ant tests

2.2.5. Running Keel

The defualt deployment of Keel runs embedded in a Struts webapp that is deployed using Tomcat-5.0. To run Keel, we simply need to start Tomcat using the command:

cd $KEEL_PROJ
ant tomcat-start

Keel can now be accessed from a web browser by accessing the url . Before moving on to anything else, Keel's internal database tables for user login and security must be created. To do this, access .

Next, access Keel's main menu from . From there, access the Users->Login menu, and login as user "root" with password "root".

If all goes well, Keel will log you in. Otherwise, look for relevant logs in $KEEL_HOME/keel-build/deploy/jakarta-tomcat-5.0.19/logs and in $KEEL_PROJ/webapp/WEB-INF/keel/server/logs.

2.3. Creating User Modules

Now that we have Keel itself installed and running properly, it is time to create our own app. For the purposes of this example, we'll create an application called "Hands On Java". This is the "app-hoj" example application that is distributed with Keel.

2.3.1. Creating the Directory Structure

To create the skeletal directory structure for a Keel application, type the following:

cd $KEEL_PROJ
ant new-app

When prompted for the name of the module being created, enter a name of our choice. Following Keel best practice, we will name our application with an "app-" prefix, and call it "app-hoj". After the Ant script finishes execution, you should have a $KEEL_PROJ/app-hoj directory.

Later, when you create Keel services, the process will be very similar to that used for creating applications. Instead of using "ant new-app", to create directory structure for a service "ant new-svc" would need to be used.

2.3.2. Incorporating into Keel's Build System

It is fairly simple to add the newly created application module into Keel's build system. Using a text or XML editor of your choice, edit the $KEEL_PROJ/user-modules.xml file. In it, add an Ant target for your custom application, as follows:

<target name="custom:app-set">
  <moduleant name="app-hoj" dir="${project.dir}" if="app.hoj"/>
</target>

The "if" attribute in the XML snippet above tells the build system to include the app-hoj module only if the property in the "if" attribute is defined. To define that property put the following in $KEEL_PROJ/ant.properties:

app.hoj=true

If and when you later add more applications into your project, simply add more "<moduleant>" targets for each application you add.

If you are sharing the same application amongst multiple projects, then you can move the application directory away from the project where it was created and put it somewhere else in your local filesystem. Then you have to do two other things. First, in $KEEL_PROJ/user-modules.xml change the appropriate "moduleant" element and adjust the "dir" attribute to point to where in the filesystem the application can be located. Second, in the application's build.xml, change the value of the "keelmodule" property to again point to where the application can be located on the filesystem.

If in the future you add a service to our project, then adding it to Keel's build system would be very similar to how an application is added. The only difference is that the "moduleant" element for services is nested within a "custom:svc-set" target rather than the "custom:app-set" target used for applications.

2.3.3. Building with new application

Now that we have our directory structure created, we need to populate with application source, JARs to satisfy dependncies, config for the applications and services. The documentation for app-hoj provides more information about the directory structure. Look in the app-hoj document or the Keel manual for an explanation of the directory structure. As a quick reference, a module's Keel-server-side source goes in <module>/src/java, and the Keel-client-side source goes in <module>/src/client. The configuration file snippets go in either <module>/conf/server or <module>/conf/client. The custom JARs that the module depends on should be put in <module>/lib or <module>/clientlib.

As a shortcut to get us going faster, we are simply going to copy the app-hoj module from the Keel distribution in $KEEL_HOME and place it in the project directory, i.e. $KEEL_PROJ.

Building all the user modules in your application is accomplished by simply typing:

cd $KEEL_PROJ
ant build

The very first time you add a new module in your project, you must include the config for the new module in the various config files in $KEEL_PROJ/conf. You can do that manually, if you choose. Or, you can merge the module's config-file snippets automatically by running the following (after "ant build" has been run):

cd $KEEL_PROJ
ant generate-config
ant install-config

As the above step will warn you, this will regenerate the merged configuration, but you will loose any modifications you previously made to Keel configuration. Any custom changes to Keel configration will need to be remade at this point.

2.4. Quick Summary for the Expert/Impatient

  • Install JDK-1.4, and make sure JAVA_HOME environment variable is set properly

  • Install Ant-1.6.1, and make sure ANT_HOME environment variable i set properly

  • Get a Keel source or binary distribution, and unzip into local filesystem. Alternatively, get Keel from CVS by checking out the "all" module. The directory where Keel is installed (i.e. the parent directory of "keel-build") should be defined by the KEEL_HOME environment variable

  • Change directory to $KEEL_HOME/keel-build and run "ant". This will create a Keel project in a directory that you are prompted for. Call the Keel project directory KEEL_PROJ.

  • Change directory to $KEEL_PROJ, and type "ant completeinstall". This will download Tomcat and Struts, assuming you have net access. If you don't, then somehow acquire Tomcat-5.0.19, Struts-1.1 distribution ZIP files and put those in $KEEL_HOME/keel-build/deploy; run "ant nonetinstall".

  • When build completes, run "ant tomcat-start"

  • Create Keel databases by accessing http://localhost:8080/default/model.do?model=createdb

  • Access Keel with http://localhost:8080/default/model.do?model=nav.navigate-seq. User is root, password is root.

  • You can change what client framework to use, what DB to use, what distribution method to use, etc., by changing $KEEL_PROJ/ant.properties. See $KEEL_HOME/keel-build/example-projects for examples. If you cahnge ant.properties, run "ant clean", followed by "ant build-all".

  • To create custom applications and services, run "ant new-app" or "ant new-svc". Once "ant completeinstall" or "ant build-all" has been run once, only "ant build" needs to be rerun subsequently.