Saturnboy
 7.1

Getting started with LCDS 3 Beta and MySQL, Part 1

, ,

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.

Setup MySQL
  1. Install & start MySQL (this is an exercise for the reader, I remember it being a little painful on my Mac)
  2. 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 user in any part of a username (ex: myuser doesn’t work) because it is a reserved word in MySQL.

  3. 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)
      );
  4. 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.

Setup LCDS
  1. Grab LCDS 3 Beta from Adobe Labs (download)
  2. Run installer & choose to install with bundled Tomcat (on Mac this installs to /Applications/lcds and the bundled Tomcat to /Applications/lcds/tomcat)
  3. Create a new LCDS app, by copying the template app (in lcds/tomcat/webapps/lcds) to a new folder:
    • cd /Applications/lcds/tomcat/webapps
    • cp -R lcds myapp
  4. 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.
    • Edit /Applications/lcds/tomcat/webapps/myapp/WEB-INF/web.xml
    • Uncomment the entire RDS section
    • Set userAppserverSecurity = false (in the newly uncommented RDS section)
  5. Update services-config.xml to avoid collisions with template lcds app:
    • cd /Applications/lcds/tomcat/webapps/myapp/WEB-INF/flex
    • Edit services-config.xml:
      • 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

    NOTE: As an alternative, you can just remove the template lcds app and skip the collision avoidance stuff above.

Setup LCDS to talk to MySQL
  1. Get MySQL Connector/J, and be sure to match the version to your MySQL version (download)
  2. Put mysql-connector-java-5.1.7-bin.jar into Tomcat’s lib folder:
    • cp mysql-connector-java-5.1.7-bin.jar /Applications/lcds/tomcat/lib/
  3. Config Tomcat to recognize your MySQL db by creating a new Context for your app:
    • cd /Applications/lcds/tomcat/conf/Catalina/localhost
    • 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>
Start LCDS
  1. Point Tomcat to the bundled Tomcat installed with LCDS:
    • export CATALINA_HOME=/Applications/lcds/tomcat
    • Windows: set CATALINA_HOME=C:\lcds\tomcat
  2. Set Java to Java 6:
    • export JRE_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
    • Windows: set JRE_HOME=C:\Program Files\Java\jdk1.6.0_14\jre
  3. Run it:
    • /Applications/lcds/tomcat/bin/catalina.sh run
    • Windows: C:\lcds\tomcat\bin\catalina.bat run
  4. 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.
  5. Verify it all worked by browsing to:
    • http://localhost:8400/myapp/
  6. 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
    • Windows:
      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
More Docs
  1. What’s new in LCDS 3
  2. LCDS Dev Guide (zip)
  3. 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.


Comments

7.14.2009

1

Thanks for your post which explains step by step to configure the mysql database

Please post part 2 version of this article ASAP.

Corby James

3.15.2010

2

When I’m building the model, I get this error:

The destination "null" used by service "ConsultantsService" was not found
in the services configuration file. Update the config file and refresh the service
in the Data/Services view.

I’m not sure what configuration file this refers to. Any ideas?

3.15.2010

3

@Corby: Seems like FB4 doesn’t like the LCDS service. I have a one idea:

Sometimes seems like LCDS doesn’t automatically regenerate the generated code when you make changes to the model.

So here’s a helpful trick to force regeneration: Switch to the Flash Builder perspective, go to the Data/Services view, and click the Edit Active Data Model icon. For some unknown reason this seems to force code regeneration.

3.27.2011

4

Hi, This is a great post. Thanks so much for the detailed instructions. I would have had no idea how to do this.

I’m having one problem though. Everything in Part 1 and Part 2 works until I try to expand “Tables”. It tells me it couldn’t connect to the database.

I’m wondering if there is anyway to directly test the configuration to mysql?

Thanks again

3.28.2011

5

@Chris: Sorry, I haven’t touched LCDS is almost 2 years. Obviously, you’ll want to double check all the usual stuff: db username, db password, db name, db privileges, etc.

After that, you are on your own. Good luck!

3.28.2011

6

Thanks. It’s still a great post.

3.28.2011

7

Just in case anyone else comes across this thread, the problem had something to do with leaving the lcds app in place. No matter what I did with ports, I still got port conflicts.
Just move the lcds app, and all is OK.
See this thread http://forums.adobe.com/thread/627988.
regards
Chris

© 2017 saturnboy.com