4.06.2008

Easy Setup Guide for BlazeDS: Zero to hero in (less than) an hour with Amazon EC2

Ever wanted to get started with BlazeDS? A bug bit me yesterday that forced me to sit at my computer for hours on end until I could achieve two things: setting up Amazon's EC2 Webservice and getting up and running with BlazeDS.

I had to do quite a bit of hunting due to my inexperience with a few things, which led me to the conclusion that someone else out there might want to benefit from my Googling and bookmarking.

Anyone who is on a Mac (I'm on Leopard) should be able to follow along fairly easily, and if you're on Windows, it shouldn't be too bad to translate.


Setting up EC2

Shared hosting is soon become something of yesteryear. With resources like Amazon's Web Services, you can set up and have complete control over your own virtual web server with a very reasonable (and sensible) pricing system. It's ultra-scalable. You only pay for the storage, transfer, and server instances that you use. Little use = little money, yet if you find yourself having to scale for whatever reason, Amazon doesn't require you to do anything. You just get the bill for the extra usage that month. Perfect for someone like me.

Step 1: Sign up for EC2

This one's pretty easy, and I won't go into too much detail unless you have great difficulties filling out forms and registering credit card information.
The important part of this is that you'll get two things that are vital for your EC2 setup: a X509 certificate and a private key file. You can access these through the "View Access Key Identifiers" link under "Your Web Services Account." Your files should look something like this:

  • cert-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CL.pem
  • pk-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem
  • On to the next step.

    Step 2: Set up command line tools

    For this step, you'll need to start Terminal and have downloaded the command line tools from Amazon. The command line tools are simply some java classes that need to be unzipped to the location of your choice. I unzipped them to this location (.ec2) that I created: /Users/Cahlan/.ec2/

    Now we're going to set up some environment variables. This will allow your ec2 command line tools to function. There are only a few, and you input them like so:
    export EC2_HOME=/path/to/unzipped/tools

    Mine was /Users/Cahlan/.ec2 or ~/.ec2 if you're already in the "Cahlan" folder.

    export PATH=$PATH:$EC2_HOME/bin

    export EC2_PRIVATE_KEY=~/.ec2/pk-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem
    This sets our private key file, and

    export EC2_CERT=~/.ec2/cert-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem
    this sets our certificate file.

    And since I'm on a Mac, I also have to set the environment variable for JAVA_HOME: JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home/


    Some helpful links for this section:
  • EC2 Development Guide
  • Jesse Andrews: EC2 Setup

  • Step 3: Create keypair

    One last step before we get dirty. We have to create a keypair so that we can authenticate with the web service. You'll do this with this command "ec2-add-keypair gsg-keypair" which will output the key to the terminal. I tried copying and pasting this into a text file with disastrous results. We'll just store the output to a file, it's a much easier way:
    ec2-add-keypair gsg-keypair >> /Users/Cahlan/.ec2/keypair

    Now the keypair is stored in a file called "keypair" in our .ec2 folder. We have to make sure the file is protected, or our SSH sessions won't work. Type this command to set the right permissions for your newly-made keypair file:
    chmod 600 /Users/Cahlan/.ec2/keypair


    Now we'll actually create our virtual server on EC2.

    Step 4: Create Server Instance

    If you've done everything right up until this point, you should be able to type the command
    ec2-describe-images -o amazon
    to see all of the available Amazon-supported images that you can use. If that didn't work, you'll need to review the previous steps to find out where you went wrong.


    So, now we need to pick an image. I chose a Linux Fedora distro with Apache and MySQL already installed, looks like this: ec2-public-images/fedora-core4-apache-mysql.manifest.xml

    To actually install this image, you'll type a command similar to this:
    ec2-run-instances ami-25b6534c -k gsg-keypair

    We got that ami code from the previous "describe" command. This will start your instance up and running. You may need to wait a few moments for it to fully initialize, you can check the progress with
    ec2-describe-instances

    You'll know it's up and running when you see something very similar to this:
    RESERVATION r-xxxxxxxx ############ default
    INSTANCE i-xxxxxxxx ami-25b6534c ec2-##-##-##-##-##-##.z-2.compute-1.amazonaws.com running gsg-keypair

    Sweet! Now we need to quickly enable some ports:
    ec2-authorize default -p 22
    for SSH,
    ec2-authorize default -p 80
    for HTTP, and
    ec2-authorize default -p 8400
    for Tomcat/BlazeDS.

    Test your new setup by navigating to this URL in your web browser: "ec2-##-##-##-##-##-##.z-2.compute-1.amazonaws.com" replacing of course the "#" with the correct numbers from your ec2-describe-instances statement.

    We're halfway there.

    Some helpful links for this section:
  • Rober Sosinksi: EC2 w/ Mac OSx
  • Jesse Andrews: EC2 Setup

  • Set up BlazeDS

    Step 5: Download Java JDK

    Now we'll SSH into our server with the following command:


    ssh -i /Users/Cahlan/.ec2/keypair root@ec2-##-##-##-##-##-##.z-2.compute-1.amazonaws.com

    If you've done everything right, you'll see some ASCII art and a greeting from Amazon.


    Now we need the Java JDK installed. After changing to the root directory and creating a directory called "java" (mkdir java), I executed a wget:
    wget -O /java/jdk-6u5-linux-i586.bin http://192.18.108.228/ECom/EComTicketServlet/BEGIN2FCA82FFFBA7733BAEFFC22E660E1F22/
    -2147483648/2647525119/1/877946/877802/2647525119/2ts+/westCoastFSEND/
    jdk-6u5-oth-JPR/jdk-6u5-oth-JPR:4/jdk-6u5-linux-i586.bin
    (line wrapped)
    You'll need to verify with the Java website that you get the correct URL. Your URL will probably be similar, or at least as painfully long.

    A couple last steps, we'll change the permissions on the bin file and then execute it:
    chmod +x /java/jdk-6u5-linux-i586.bin
    ./java/jdk-6u5-linux-i586.bin
    You'll need to agree to the terms displayed in the output and then java will be installed.
    Before we move on, let's set the appropriate environment vars for our BlazeDS to work.
    export JAVA_HOME=/java/jdk1.6.0_05/bin
    Some helpful links for this section:
  • JDK Downloads Page
  • JDK Install Instructions

  • Step 6: Download BlazeDS

    We're pretty close now. We need to download BlazeDS, doing something very similar to what we did for the JDK:
    Go back to root, make a "blaze" directory: cd ../
    mkdir blaze
    cd blaze
    wget http://download.macromedia.com/pub/opensource/blazeds/blazeds_turnkey_3-0-0-544.zip
    We're using the turnkey download of BlazeDS because it comes packaged with an integrated Tomcat server.
    Now we just need to unzip the file:
    unzip blazeds_turnkey_3-0-0-544.zip

    Step 7: Startup Tomcat

    Finally, we'll start our newly unpacked Tomcat server using this command:
    ./blaze/tomcat/bin/startup.sh
    We should also start the sampledb for the samples app to work correctly:
    /blaze/sampledb/startdb.sh


    Some helpful links for this section:
  • BlazeDS Install Guide
  • BlazeDS Release Builds

  • Step 8: Check it Out

    You can now admire and test your newly deployed BlazeDS install by going to http://your.long.url.amazon.com:8400

    Not bad for implementing an entire LAMP setup along with Tomcat and BlazeDS in one sitting! See how your boss/clients react when you use all of these buzzwords in a sentence: Amazon EC2, Linux Fedora, Compute Cloud, BlazeDS, Tomcat. Kudos for whoever can make the sweetest sounding sentence with all of these. Or maybe some sweet rhyme?

    3.31.2008

    Papervision3D + Tweener + After FX = wowzers!

    Excuse the silly title, I just wanted to grab your attention and proudly announce that my company's new website is finally finished, www.sandmanstudios.com! Sandman Studios is a full-service creative agency specializing in CG Animation, Visual Effects Production, and Interactive Multimedia.


    We had a lot of big ideas of what we wanted to put into the new site and we have a lot more cool things in store, but for the time frame we had to work with, I think we did a great job on phase one of it. We used Papervision 3D on several project detail pages. For example, check out the Papervision 3D in this project called, "The Terrible Tooth". Also, I used Tweener extensively throughout the site. We used After FX in a lot of places, like in the Gorilla animation we did for the LA Zoo.

    Not only did we create an amazing website, we also built a custom content management system in Flex to manage it. Which, I am now regretting because my boss wants us to create these for every site we do now. We used AMF PHP for the Flash to database communication. Which made it possible for us to get the CMS up and running in a few days. We also use SWFAddress for the deep linking.


    It was nice to work on something for ourselves for once. Even though we were our own client, I think we all realize that even we don't know what we want until we see it.

    Labels: , ,

    2.12.2008

    BlazeDS = AMF/LiveCycle?

    I've been lucky over the years to always have someone that can build the back-end data structure for a project. But, as a result, I've let myself become less knowledgeable as I should be on what technologies to use and work best in certain situations. So lately I've been trying to get up to speed in this area and have been playing around with RubyAMF, AMF PHP, and SWX PHP as solutions for Flash/Flex to server communication.

    I've been the most impressed with technologies that use AMF (Action Message Format). AMF is a binary format for exchanging data. It's mostly used to transfer data between Flash/Flex applications and a database via a remoting request. In a remoting call, the external elements being called would be application tier services, which would likely be running on an application server such as Adobe ColdFusion, Java, PHP, or .NET.

    The major benefits of using AMF for remoting requests are speed and packet size. The use of a AMF binary data transfer format increases performance, allowing applications to load data up to 10 times faster than with text-based formats such as XML or SOAP.

    Adobe evangelist James Ward has a Flex application on his site that enables you to run some AMF benchmark tests. Census RIA Benchmark demonstrates various methods of loading data in RIAs and determines how those methods affect performance, bandwidth, and client memory usage.

    So, where am I going with this? Well, Adobe released source code for its remoting and messaging technologies under a new open source product named BlazeDS.

    An open source Java implementation of AMF, BlazeDS includes technologies that were previously available only as part of LiveCycle Data Services (LCDS) . With BlazeDS, developers can easily connect to back-end distributed data, as well as push data in real time to Flex and AIR applications, for more responsive RIA experiences.

    According to Adobe, the company plans to contribute the proven technologies from LCDS to the community through BlazeDS. The two LCDS technologies included in the first release are the Messaging Service and the Remote Procedure Call (RPC) Services:

    • Messaging Service: The Messaging Service provides publish and subscribe messaging for Flex and Ajax applications. Messaging uses the Java Message Service (JMS) to provide real-time communication between connected clients and JMS-compatible application servers, such as ColdFusion. This enables you to create scalable, reliable applications for collaboration and data push, such as chat applications or real-time stock quote applications.
    • RPC Services: The RPC Services (aka Flash Remoting) are designed for applications in which the request/response model is the best choice for accessing data. It enables the use of HTTP services, SOAP-based web services, and Plain Old Java Objects (POJOs) with the efficient AMF 3 protocol. The biggest benefit of using RPC Services in LCDS is the ability to call Java services directly without needing to configure them as SOAP-compliant web services.
    It keeps getting less and less expensive to develop Flex applications. The Flex SDK is free and includes a command-line compiler and the entire library of Flex framework class files. BlazeDS will be free and includes some of the functionality from LiveCycle. Its a good time to be a Flash/Flex developer.

    Labels: , , , , ,

    2.06.2008

    Passing ...rest arrays to another function

    Quick tip on how to pass ...rest arrays to another function. I ran into this on my current project at work and wasted a good half hour or so before I figured it out. Duh!

    private function myFunction1(strVar1:String, objVar2:Object, ... rest):void {
    myFunction2.apply(null, [strVar1, objVar2].concat(rest));
    }

    Labels: , ,

    2.05.2008

    Yahoo! releases Flash CS3/Flex components

    Yahoo! Developer Network releases ASTRA, the ActionScript Toolkit for Rich Applications. A collection of Flash and Flex components, code libraries, toolkits and utilties developed by Yahoo! for ActionScript developers.

    ASTRA Flash components comes with the Tree, Menu, TabBar, AutoComplete, Charts, AlertManager, AudioPlayback, and MenuBar components for Flash CS3.

    ASTRA Flex components include AutoCompleteManager, ColorPlaneAndSliderPicker, ColorSliderPicker, DropDownColorPicker, IPv4AddressInput, TimeInput, and TimeStepper components for Flex.

    Labels: , , ,

    1.08.2008

    Flex (Now LiveCycle) Data Services: A Beginner's Perspective


    I got the chance over the last few months to work on a very cool project that required some pretty advanced (well, complex at least) architecture and abilities. I thought of LiveCycle Data Services and decided to look a little more into what it could do.


    First, LiveCycle Data Services is really powerful. It includes four basic services that run as "middleware" (i.e. between the server and client sides). The services are Proxy Service, Messaging Service, Data Management Service, and Remote Object Service. My project only required the Messaging and Remote Object services, and believe me, I really only scratched the surface on these technologies. There are many, many cool things you can do with LCDS.


    That being said, I wanted to record here a few thoughts and pieces of advice for others who are just starting to get to know this technology.


    First, and probably the most daunting for me, was that you're going to have to get to know Java servers. My experience up until this point had been strictly limited to Windows or Linux running Apache, and even in those areas I was practically a beginner. Believe me, it was quite the task to get to learn Java servers. LCDS comes with an installation of Adobe's integrated Jrun server, which I ended up using, although you can use a number of Java servers (JBoss, Jrun, etc).


    Second, and you might have seen this coming, but you'll need to get to know Java itself to a degree. I would say this largely depends on the requirements of the project, but for mine luckily it wasn't too bad. Also lucky was the fact that learning to write basic Java classes really wasn't that bad either. ActionScript 3.0 is a great prep :)


    Finally, get to know Google. This is kind of tongue-in-cheek, but there were more than a bunch of times that I ran into a wall with either the server, LCDS or Java in general and I spent a lot of time trying to search for answers. One extremely helpful resource that I referred to a lot was David Gassner's Lynda.com series on Flex Data Services. It's slightly outdated, but still contains a lot of relative and extremely helpful tips on building your LCDS project in Flex. Here's a few things I saved for future reference, maybe they can help you out:


    • If you're getting an error with the server with loading MessageBrokerServlet, try this page

    • If you're having some problems with your server not loading classes, you may want to check your jrm variables on your server

    • For the Messaging service, check this page if you're having trouble with RTMP running on port 2038

    • A common error trying to use MySQL involving a "handshake error" is resolved here

    • When configuring your remote object services (remoting-config.xml), be sure to use different names for a channel and service (i.e. channel = "products" and service = "Products")



    Hopefully this helps if you're just getting started with LiveCycle Data Services. Again, I really had a blast with this technology overall and hope to be able to use it again in the future. Feel free to post any useful thoughts or pieces of advice you've come across as well!

    Labels: , ,

    10.05.2007

    From designer to developer using Adobe "Thermo"

    I wasn't able to attend Adobe Max this year :*( . So I've been watching all the video coverage posted on the web and I have to say I'm very excited for Adobe's designer to developer app, code named, "Thermo". Aral Balkan posted some videos of Adobe showing it off at Max:

    Thermo Sneak Peak - Part 1
    Thermo Sneak Peak - Part 2
    Thermo Sneak Peak - Part 3

    Adobe also gave a sneak peek at Flash 10, code named "Astro". It has a ton of features that users have dreamed about for years. Like a multi-column text engine, native 3D, and a new filter effect scripting language called Hydra.

    Flash 10 "Astro" Sneak Peek

    Labels: , , ,