Personal tools

LZProject

From OpenLaszlo

Contents

LZProject

LZProject is the OpenLaszlo 4.x blueprint application. This page contains the build instructions for the LZProject application.

Screen cast showing the build process

There's a screen cast as RealMedia video available at the Internet Archive showing the whole process of building LZProject. The file size is about 30mb and can be played with the RealPlayer (before you complain about the file format: a Quicktime file with the same quality would have been 5 times as big!).

Environment

You should have working version of the JDK 1.5.x installed and Apache Ant (1.6 or 1.7).

Calling javac -version in your terminal should give a similar output:

 > javac 1.5.0_07
 > javac: no source files
 > Usage: javac <options> <source files>
 > ...

Run the same test for your Apache Ant installation with the command ant -version:

 > Apache Ant version 1.7.0 compiled on December 13 2006

The $JAVA_HOME environment variable needs to be set as well, pointing to the base directory of your JDK installation. The same is true for $ANT_HOME, pointing to your Apache Ant installation directory. $ANT_OPTS must be set to "-Xms256M -Xmx1024M", as the OpenLaszlo compiler needs more memory than the default JVM settings.

Then you need an installation of Apache Tomcat 5.0.x. $CATALINA_HOME variable should point to your Tomcat installation folder, and the folder $CATALINA_HOME/bin should be added to your path.

Here's an example for the set of environment vars which need to be set to compile LZProject from the source code. $CATALINA_OPTS only need to be set if you plan to deploy the PROXIED version of LZProject with the OpenLaszlo server. The default memory limits for the JVM are not sufficient to compile LZX files:

 export JAVA_HOME=/Library/Java/Home
 export TOMCAT_HOME=~/java/tomcat5
 export CATALINA_HOME=$TOMCAT_HOME
 export CATALINA_OPTS=" -Xms256M -Xmx1024M"
 export ANT_HOME=~/java/apache-ant
 export ANT_OPTS="-Xms256M -Xmx1024M"
 export PATH=$PATH:${ANT_HOME}/bin:${TOMCAT_HOME}/bin

Test if you can start and stop the Tomcat server by executing startup.sh and shutdown.sh. The output should look similar to this:

 > noname:~ raju$ startup.sh
 > Using CATALINA_BASE:   /Users/raju/java/tomcat5
 > Using CATALINA_HOME:   /Users/raju/java/tomcat5
 > Using CATALINA_TMPDIR: /Users/raju/java/tomcat5/temp
 > Using JAVA_HOME:       /Library/Java/Home
 > noname:~ raju$ shutdown.sh
 > Using CATALINA_BASE:   /Users/raju/java/tomcat5
 > Using CATALINA_HOME:   /Users/raju/java/tomcat5
 > Using CATALINA_TMPDIR: /Users/raju/java/tomcat5/temp
 > Using JAVA_HOME:       /Library/Java/Home
 > noname:~ raju$

Check out LZProject source code from SVN

The LZProject source code can be found at svn.openlaszlo.org/lzproject/trunk. You need a Subversion client to check out the source code. Once you have installed a client, you can checkout (in case you are working with a terminal client) by executing

 > svn co http://svn.openlaszlo.org/labs/lzproject/trunk lzproject/trunk

In case you don't have any source code folder yet it makes sense to create a sub folder structure like ~/src/svn into which you check out LZProject source code. The checkout will take a little bit of time, depending on the connection speed.

Once that process is finished, go into the lzproject/trunk folder.

Download OpenLaszlo 4.x Servlet WAR

To build LZProject we need the OpenLaszlo compiler contained within the OpenLaszlo server. You need to download a version of the OpenLaszlo Servlet WAR from the OpenLaszlo download page. The current stable 4.x release is OpenLaszlo 4.0.3 Servlet.

Save the OpenLaszlo Servlet WAR into lzproject/trunk/openlaszlo folder. Rename the file from *.war to *.zip and unzip the file content. In my case the folder containing the OpenLaszlo server is called OpenLaszlo-4.0.3-servlet.

The ANT script has to be informed of the name of this folder, and that can be done through a configuration parameter in lzproject/trunk/ant.properties file. Here's he content of that file:

 # OpenLaszlo configuration
 openlaszlo.version=openlaszlo-4.0.3-servlet
 
 # Tomcat server for deployment
 tomcat.host=localhost
 tomcat.port=8080
 tomcat.user=admin
 tomcat.password=laszlo

The entry openlaszlo.version has to match the folder name where the OpenLaszlo server was unzipped into, e.g.

 lzproject/trunk/openlaszlo/openlaszlo-4.0.3-servlet

The last thing we need to do before starting the build process is to enter a user into our Tomcat user file, so that ANT can automatically deploy or undeploy webapps to the server. You'll find the config at

 $CATALINA_HOME/conf/tomcat-users.xml

This is what my config file looks like:

 <?xml version='1.0' encoding='utf-8'?>
 <tomcat-users>
   <role rolename="tomcat"/>
   <role rolename="role1"/>
   <role rolename="standard"/>
   <role rolename="manager"/>
   <role rolename="admin"/>
   <user username="tomcat" password="tomcat" roles="tomcat"/>
   <user username="both" password="tomcat" roles="tomcat,role1"/>
   <user username="admin" password="laszlo" roles="standard,manager"/>
 </tomcat-users>

The highlighted entry username="admin" and password="laszlo" has to correspond with the values in the ant.properties file:

 # Tomcat server for deployment
 tomcat.host=localhost
 tomcat.port=8080
 tomcat.user=admin
 tomcat.password=laszlo

In case your server is not localhost or you are using another port than 8080 that can be adjusted here as well. Remember: If you did any changes in the tomcat-users.xml, you have to restart your Tomcat server to pick up the changes.

Starting the build process

Now, that all preparations have been finished, the fun begins. Go into your lzproject/trunk folder and just enter ant:

 > noname:~/src/svn/lzproject/trunk raju$ ant 
 > Buildfile: build.xml
 > 
 > clean:
 >      [echo] Apache Ant version 1.7.0 compiled on December 13 2006
 >    [delete] Deleting directory /Users/raju/src/svn/lzproject/trunk/builder
 >    [delete] Deleting directory /Users/raju/src/svn/lzproject/trunk/temp/lzproject/javadocs
 >    [delete] Deleting directory /Users/raju/src/svn/lzproject/trunk/temp
 >    [delete] Deleting directory /Users/raju/src/svn/lzproject/trunk/distribution
 > 
 > init:
 >     [mkdir] Created dir: /Users/raju/src/svn/lzproject/trunk/builder
 > 
 > ... many more lines of output from ant ...
 > 
 >       [war] Building war: /Users/raju/src/svn/lzproject/trunk/distribution/lzproject-solo.war
 > 
 > build:
 >      [echo] Building LZProject OL 4.0 app...
 > 
 > BUILD SUCCESSFUL
 > Total time: 25 seconds

If you look into your lzproject/trunk/distribution folder you'll see the following file:


 > noname:~/src/svn/lzproject/trunk raju$ cd distribution/
 > noname:~/src/svn/lzproject/trunk/distribution raju$ ls
 > lzproject-solo.war

You can directly copy that file into your $CATALINA_HOME/webapps folder and wait a few seconds (if auto-deployment of WARs is activated for your server), or have the WAR deployed to Tomcat for you by ANT.

Starting a build with the target

 > ant deploy-solo-war

should give you the following output (only copied the last few lines of ANT output here), if everything went well.

 >       [war] Building war: /Users/raju/src/svn/lzproject/trunk/distribution/lzproject-solo.war
 > 
 > deploy-solo-war:
 >    [deploy] OK - Deployed application at context path /lzproject-solo
 >    [deploy] 
 >      [echo] You can access the application at http://localhost:8080/lzproject-solo
 > 
 > BUILD SUCCESSFUL

If you navigate your browser to http://localhost:8080/lzproject-solo (in case you are deploying on your local machine) you will see the LZProject start page.

Useful ANT build targets

The following ANT targets should be useful:

 ant deploy-war
 ant undeploy-webapp
 ant deploy-solo-war
 ant undeploy-solo-webapp

What does SOLO mean here? The OpenLaszlo server has two deployment modes, called PROXIED and SOLO. SOLO means, that the OpenLaszlo application (LZX files) is only compiled and then can be executed with out having OpenLaszlo installed on your web server. PROXIED mode of deployment means, that an OpenLaszlo server is present as part of your web application, and it means you can compile the LZX files as well.

Apache Derby Database

Apache Derby is a Java embedded SQL database. If you want to do any changes on the Derby database, here's what you need to do:

 1) Download the binary distribution of Apache Derby from http://db.apache.org/
    LZProject uses version 10.2 of Derby.
 
 2) Extract the file into any folder you select, and then
    a) Set the DERBY_HOME environment variable
    b) Include the DERBY_HOME\bin directory in the PATH environment variable
 

If you added $DERBY_HOME/bin to your $PATH, you can use the interactive ij command to connect to the database: If you launch ij you have to first execute the connect command to load the LZProject database. In the line

 connect 'jdbc:derby:/Users/raju/src/svn/lzproject/trunk/derby/WEB-INF/lzprojectdb';

you have to adjust the path to the Derby database folder so that it matches your system.

 machine:~ raju$ ij
 ij version 10.2
 ij> connect 'jdbc:derby:/Users/raju/src/svn/lzproject/trunk/derby/WEB-INF/lzprojectdb';
 ij> SELECT * FROM USERS;
 ID     |LOGIN             |REAL_NAME             |EMAIL                            |PASS               |LAST_LOGIN                
 -------------------------------------------------------------------------------------------------------------------------------
 1      |laszlo           |Laszlo Moholy-Nagy     |laszlo.moholy@openlaszlo.org     |E439796B...        |2007-05-11 03:01:08.161   
 2      |david            |David Temkin           |dave@openlaszlo.org              |E439796B...        |2007-05-05 15:33:59.227                        
 ...
 7 rows selected
 ij> exit;
 machine:~ raju$

Now you are ready to execute an Derby compatible SQL command on the database. The tables used by LZProject are USERS, PROJECTS and TASKS. You'll find some basic information on ij usage here: http://db.apache.org/derby/papers/DerbyTut/ij_intro.html