With the beta release of LiveCycle Data Services 3, Adobe has changed the game by bringing model driven development to the forefront. The geniuses from the entity formerly known as Macromedia have put together a compelling product if you are in the business of enterprise RIAs like us. Here are a few choice words from Adobe about the beta release.
Now on to the fun part: playing with our new toy. Vroom, vroom! In Part 1, I’ll walk through getting started with LCDS sitting on top of MySQL. Part 2 covers using the Modeler plugin in Flash Builder 4 to bring the dream of model driven development to reality.
NOTE: This article was written for LCDS 3 Beta 1, but I assume it’s mostly relevant for Beta 3 (released at AdobeMAX) and all future versions of LCDS 3.
NOTE 2: The Mac installer for Beta 3 (released at AdobeMAX) does not included the integrated Tomcat which is a huge pain in the ass for all Mac developers. I recommend you grab the integrated Tomcat out of the Windows installer.
- Install & start MySQL (this is an exercise for the reader, I remember it being a little painful on my Mac)
- Create a new db & user:
mysql -uroot -p
CREATE DATABASE mydb; CREATE USER 'myusr'@'localhost' IDENTIFIED BY 'mypassword'; GRANT ALL PRIVILEGES ON mydb.* TO myusr@localhost;
NOTE: Don’t use
userin any part of a username (ex:
myuserdoesn’t work) because it is a reserved word in MySQL.
- Create some sample tables:
mysql -umyusr -pmypassword mydb
DROP TABLE IF EXISTS team; CREATE TABLE team ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(150), PRIMARY KEY (id) ); DROP TABLE IF EXISTS player; CREATE TABLE player ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(150), NUMBER INT NOT NULL, salary INT NOT NULL, team_id INT NOT NULL, PRIMARY KEY (id) );
- Insert data:
INSERT INTO team (name) VALUES ("Denver Broncos"); INSERT INTO team (name) VALUES ("Oakland Raiders"); INSERT INTO player (name,NUMBER,salary,team_id) VALUES ("Jay Cutler", 6, 6497500, 1); INSERT INTO player (name,NUMBER,salary,team_id) VALUES ("Champ Bailey", 24, 8003050, 1); INSERT INTO player (name,NUMBER,salary,team_id) VALUES ("Eddie Royal", 19, 2539830, 1); INSERT INTO player (name,NUMBER,salary,team_id) VALUES ("Tony Scheffler", 88, 612480, 1); INSERT INTO player (name,NUMBER,salary,team_id) VALUES ("JaMarcus Russell", 2, 16872400, 2); INSERT INTO player (name,NUMBER,salary,team_id) VALUES ("Darren McFadden", 20, 4375000, 2); INSERT INTO player (name,NUMBER,salary,team_id) VALUES ("Sebastian Janikowski", 11, 2625000, 2);
NOTE: Ignore the fact that Jay Cutler now plays for Da Bears.
Digging Deeper: Setting up a database is required, but setting up tables or inserting data is not. You can use the model driven development features of LCDS (and the Modeler plugin) to create all of your tables and data.
- Grab LCDS 3 Beta from Adobe Labs (download)
- Run installer & choose to install with bundled Tomcat (on Mac this installs to
/Applications/lcdsand the bundled Tomcat to
- Create a new LCDS app, by copying the template app (in
lcds/tomcat/webapps/lcds) to a new folder:
cp -R lcds myapp
- Enable RDS (Remove Dev Services) – This enables some dev only stuff like updating the database tables on the server directly from Flash Builder. For obvious security reasons, RDS would never be running in a production environment.
- Uncomment the entire RDS section
userAppserverSecurity = false(in the newly uncommented RDS section)
services-config.xmlto avoid collisions with template
- In the
<channel-definition id="my-rtmp">section, change port 2038 to port 2039
- In the
<channel-definition id="my-nio-amf">section, change port 2880 to port 2881
- In the
<channel-definition id="my-nio-amf-poll">section, change port 2880 to port 2881
- In the
<channel-definition id="my-nio-http">section, change port 2880 to port 2881
- In the
NOTE: As an alternative, you can just remove the template
lcdsapp and skip the collision avoidance stuff above.
Setup LCDS to talk to MySQL
- Get MySQL Connector/J, and be sure to match the version to your MySQL version (download)
cp mysql-connector-java-5.1.7-bin.jar /Applications/lcds/tomcat/lib/
- Config Tomcat to recognize your MySQL db by creating a new Context for your app:
cp lcds.xml myapp.xml
- Add a JDBC Resource block to
myapp.xml, so it looks like this:
<Context privileged="true" antiResourceLocking="false" antiJARLocking="false" reloadable="true"> <!-- JOTM --> <Transaction factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/> <!-- MySQL --> <Resource name="jdbc/MyDB" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="myusr" password="mypassword" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/mydb?autoReconnect=true"/> </Context>
- Point Tomcat to the bundled Tomcat installed with LCDS:
- Set Java to Java 6:
set JRE_HOME=C:\Program Files\Java\jdk1.6.0_14\jre
- Run it:
- Sometimes Tomcat does not get the value of
JRE_HOME(usually on Windows). The caused by a hard-coded value inside
catalina.sh, you’ll need to edit this file and comment out that line.
- Verify it all worked by browsing to:
- A helpful bash script that does #1 – #3 all in one shot:
#!/bin/bash export CATALINA_HOME=/Applications/lcds/tomcat export JRE_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home /Applications/lcds/tomcat/bin/catalina.sh run
set CATALINA_HOME=C:\lcds\tomcat set JRE_HOME=C:\Program Files\Java\jdk1.6.0_14\jre C:\lcds\tomcat\bin\catalina.bat run
- What’s new in LCDS 3
- LCDS Dev Guide (zip)
- Tutorial Video – awesome, 20 min long, and very worthwhile
To Be Continued…
That’s it for Part 1. LCDS should be up and running on top of MySQL. Next up, Part 2 covers the Modeler plugin and model driven development.