QueTwo's Blog

thouoghts on telecommunications, programming, education and technology

Tag Archives: ColdFusion Builder

CFML in the Cloud (Part 2)

This is the second part of a two part series on deploying your CFML applications to the cloud using Amazon Web Services’ Elastic Beanstalk.  Read the first part here.

Updating your application

  1. Since your app is running through your Elastic Beanstalk, making changes are not as easy as just FTPing a few files to the server.  You will have to make the changes the “Java” way.
  2. Make the changes, and preview them on your local Tomcat server.  Drop the changed CFML templates into that WebContent directory, and hit refresh in your browser.
  3. Once your changes are good on your local machine, right click on the project name, go to Run A -> On Server…
  4. Choose your AWS instance from the list, and click Next.
  5. Make sure your project is still selected to deploy and click Finish.
  6. Wait.  It will take up to 5 minutes to upload your changes to AWS.  It will then take another 5 minutes or so to merge your changes with the original project and restart Tomcat.  It will take some time, so grab a fresh drink.  You may get an error message saying that your instance took too long to start — that’s ok.  Give it a few minutes and refresh your browser to see the new version.

Setting up a Database

  1. Amazon Web Services has the ability to host regular databases as well!  You have two options:
    1. Create a new database using Amazon RDS.  This gives you much more flexibility and lets you choose between MySQL, Oracle, or Microsoft SQL.   You get one year free for one DB instance.  You can have as many tables and store as much data as you want.  You can also tell it to do automatic backups and snapshots of your DB.  This is slower for smaller queries (because it relies on TCP sockets across the network), but faster for more CPU intensive queries.
    2. Create a DB within your Elastic Beanstalk instance.  This adds no cost to your application, but limits your DB choices.  It also means that if you re-create / re-upload your application, your DB will be reset.  This is slightly faster for smaller queries, but slower for larger, more CPU intensive queries.
  2. Head over to the Amazon Management Console.  Login.
  3. If you are going with option 1, do the following :
    1. Head to the RDS section.
    2. Launch a new instance.  Choose your DB engine.
    3. Set the Instance class (this is how much CPU you will have dedicated to the DB.  t1.micro is the free one).  Choose how much space you plan to use (allocation space), and set a DB name, username and password.
    4. Go through the rest of the configuration settings and launch your DB.  It will take about 5 minutes to it to fully launch.  Once it is launched, it will give you the “endpoint”, which is the hostname of the DB.  Write this down, you will need it later.
    5. Head over to the “DB Security Groups” section.  We need to allow our server to access this DB through the firewall.
    6. Click on Default.  Under Connection Type, choose EC2 Security Group, Choose the weird looking “instance id” from the drop-down, and click Add.
    7. You may want to add your own computer to the list as well so you can manage the DB over the internet — Add your IP address by using the CIDR connection type (it will tell your computer’s IP address so you can add it properly).
    8. Your DB should be all setup.  You can connect to it from your computer using your favorite admin tool — use the endpoint as the hostname, and the login/password/db name to connect to it.
  4. If you are going with option 2, do the following :
    1. Head over to the Elastic Beanstalk section.
    2. Find your application, then the environment you launched.
    3. Click Edit Configuration under the enviroment.
    4. Go to the Database tab, and fill out the following form : 
    5. When you apply changes, it will create the DB and spin it up.  This will take a few minutes.  You will get the endpoint (hostname), the username and password when it is finished.
    6. Head to the RDS section within the AWS Management Console.
    7. Head over to the “DB Security Groups” section.  We need to allow our server to access this DB through the firewall.
    8. Click on Default.
    9. Add your own computer to the list as well so you can manage the DB over the internet — Add your IP address by using the CIDR connection type (it will tell your computer’s IP address so you can add it properly).
    10. Your DB should be all setup.  You can connect to it from your computer using your favorite admin tool — use the endpoint as the hostname, and the login/password/db name to connect to it.
  5. Go to the Railo or ACF administration interface, and add the DB.

Using the Administration Interface (Railo Specific)

  1. Chances are, you want to be able to keep your configuration settings in sync between your local computer and the AWS instance.  This is not hard, but it requires you copying some files around.  In all honesty, this is the trickest thing about running Railo in the cloud…
  2. Head over to http://localhost:8080/<projectname>/railo-context/admin/server.cfm
  3. Set a password.  The first time you go to this page, it will ask you to set one.
  4. Make your changes.  For example, setup your databases, etc.
  5. Click on the Web Administrator tab.  At least set a password.  This is the context-specific settings (you only have one context at this time, so you may want to set everything in the server admin).
  6. When finished, click back on Server Administration.  This will take you back to the dashboard.  Keep this open in the background.
  7. Back in ColdFusion Builder, create a set of new folders within the WebContent folder :
    1. WebContent\WEB-INF\lib\railo-server\context\
    2. WebContent\WEB-INF\railo\
  8. Go back to the Server dashboard.  Find the configuration file section.  Find this file on your file system, and copy it into your new \WebContent\WEB-INF\lib\rail0-server\context\  directory.  4-9-2013 9-13-51 PM
  9. Go back to the Web Administrator dashboard.  Find the configuration file section.  Find this file on your file system, and copy it into your new \WebContent\WEB-INF\railo\ directory.
  10. Any time you want to push Railo configuration file changes into the cloud, you need to repeat this process.
  11. Deploy these changes to your AWS instance by following the Updating your Application section.  Your online AWS instance will be updated in a few minutes.

Licensing Considerations (Railo vs. Adobe ColdFusion)

One thing to consider when deploying your CFML application out to the cloud is licensing.  In particular, if you are using Adobe ColdFusion there are some serious licensing implications.  NOTE:  I’m no lawyer — I only play one on TV.  Consult your legal weasel team before trusting what I say here. 

If you deploy Railo on the cloud, there is very little you have to worry about.  By being licensed under the GNU Lesser license, you are free to do pretty much what you want with it.  You can deploy, scale up, scale down, etc. without much worry.  I promise.  Oh, and the Railo team is pretty nice too ;)

If you plan on working with Adobe ColdFusion 9.x and below, know you are breaking license agreement by using AWS.  They calculate your license by the number of CPUs that you are running on.  There is no way to know that.  At all.  You could say that you are trying to be honest by having one license per instance — and I’m sure they would believe you, but you are “breaking the law.”    I’ve tested this setup with ACF 8.x, ACF 9.x and ACF 10.x (all developer editions of the WAR deployment, of course!) and had it work fine.  ACF 8.x is pretty slow on t1.micro, so be aware of that.

If you plan on working with Adobe ColdFusion  10.x, they do allow for ACF on the cloud.  You can run either 1 CF Standard  instance per license, or up to 10 CF Enterprise instances per license.  More information is available on the blog post written on the subject by the CF team.  Read the blog post carefully.  What it boils down to is if you are running a standard license, you CANNOT use the auto-scaling features of Elastic Beanstalk.  If you are running an enterprise license, you need to watch the number of licenses you are consuming at your max when scaling up, and the amount of CPU you plan on consuming.

Conclusion

I hope this tutorial helped you bring your apps to the cloud.  As I said earlier, I’ve been deploying many of my customers using this method with great success.  Please comment below if you have any questions or comments with the setup.  Enjoy!

CFML in the Cloud (Part 1)

Deploying CFML, or ColdFusion applications in the “cloud” is a lot easier than you might think. I recently deployed my 5th customer on Amazon Web Services using their Elastic Beanstalk product and once you get the hang of what is going on, it is pretty easy.

For those of you who have never heard of Amazon’s Elastic Beanstalk, it is a “cloud” product for developers.  Essentially, it allows you to take a bundle of source code and upload it to a brand new server.  You don’t have to setup the OS, configure a web server, worry about permissions, do backups or patches.  The Elastic Beanstalk will even scale your server for you if you get a lot of traffic in a short amount of time.  Best of all, Amazon gives developers 1 year worth of this service for free (you still have to pay for bandwidth and storage, but in most cases that is less than a dollar each month).  Since this is a hands-off approach you are limited as to what OS or runtime tweaks you can make…

What you will need in order to Deploy a ColdFusion app in the cloud:

  • An Amazon AWS account.  You will need to tie a phone number and credit card to your account in order to sign up.  You will get 1 year’s worth of service for free for one server.
  • A working copy of Eclipse.  I used the version that is bundled with ColdFusion Builder 2, but you can use any fairly modern version.
  • A Modern CFML Server that can deploy as a WAR file.  This includes Railo 3.2+, Adobe ColdFusion 8.x – 10.x (Enterprise edition only).  I’ll dive into licensing concerns later.  I’ve been using Railo 4.1.
  • The AWS toolkit for Eclipse.   More information about that is here.
  • Apache Tomcat.  I recommend Apache Tomcat 7.x.  You will want to grab the “Core .ZIP” file.
  • (Optional) Some sort of CFML editor.  Again, I used CFB2. CFEclipse should work equally well.

Setting up your local environment:

  1. Install Eclipse, if you don’t already have a working copy.  Install your CFML editor (or if you use ColdFusion Builder, simply use the Eclipse that comes with it).
  2. Make sure the following components are installed within Eclipse…  If you don’t see them on the list when you choose the correct repository, then they are already installed. If you are using CFB, you will need to go to Help -> Install New Software -> and choose the Indigo Repository from the Work With… drop-down :
    1. Under Web, XML, Java EE and OSGi Enterprise Development
      1. Eclipse Java EE Developer Tools
      2. JST Server Adapters
      3. JST Server Adapters Extensions
      4. JST Server UI
      5. WST Server Adapters
  3. If you installed any new components, restart Eclipse.
  4. Install the Amazon Web Services Eclipse Toolkit
    1. Go to the Help -> Install New Software…  Menu
    2. Click the Add… button next to the Work With drop-down.  This will allow you to add a new repository
    3. Add the AWS Eclipse Toolkit repository with a location of : http://aws.amazon.com/eclipse
    4. Select all the available modules, EXCEPT the following :
      1. SimpleDB Management  (This will require some modules that don’t install right)
      2. AWS SDK for Android (This will require the Android toolkit which we haven’t installed)
    5. Click install, and let Eclipse download, verify and install all the required components for AWS.  Make sure to restart Eclipse after you finish.
  5. Open the AWS Management Perspective (Click the little plus sign next to the ColdFusion icon in the toolbar).
  6. Click the down arrow on the right side of the AWS Explorer view.  Choose AWS account, then Configure AWS accounts.4-7-2013 11-30-20 PM
  7. Setup your account credentials, and give an account name.  These were provided to you during the initial setup, but there are also instructions on where to find it in the AWS management portal as well.
  8. Click Apply and OK.
  9. Take your copy of Tomcat you downloaded earlier, and unzip it somewhere where you can find it.  C:\Tomcat\ works great, but it doesn’t really matter.  You don’t need to install it, configure it or anything like that — the AWS toolkit will do this for you.

Setting up your new CFML project

  1. Switch back to the CFML perspective in Eclipse.
  2. In the Navigator, click on a blank area and choose New -> Project…   (NOT ColdFusion Project!)
  3. Choose AWS -> AWS Java Web Project
  4. Give the project a name, Select your AWS account you setup earlier, and choose Basic Java Web Project
  5. A new CF project will be created with three folders :
    1. build  — This will hold your AWS configuration.  No need to touch this.
    2. src — If you plan on adding any additional Java source-code, this is where you will do it.  Otherwise, nothing to see here.
    3. WebContent — this is your WebRoot.  It comes pre-loaded with a .JSP file, a styles folder, images folder and a WEB-INF folder.  Delete everything in this folder EXCEPT the WEB-INF.
  6. Download your CFML engine as a WAR file.  I recommend Railo, which has a .WAR file you can grab right from their website : http://www.getrailo.org/index.cfm/download/.   If you are using Adobe ColdFusion, you will need to grab and generate your .WAR file manually.
  7. Rename the .WAR file to .ZIP.  Open this ZIP file with your favorite unarchiver.
  8. Copy the contents of this ZIP file and place it in the WebContent folder.  If using the downloaded version of Railo, you will end up with some sample .CFML files and a WEB-INF directory.  Don’t touch anything in the WEB-INF or META-INF directories, but the rest of the files can be deleted.  Make sure to overwrite the web.xml file.
  9. You now have everything in place to start coding.

Testing and debugging your CFML application

  1. You will most likely want to test your application before you deploy to Amazon.  That is why we unzipped TomCat earlier!
  2. Right click on your project in the Project Explorer, go to Run As -> Run On Server…
  3. Choose “Manually define a new server”
  4. Choose Apache -> Tomcat v7.0 Server, and choose localhost as the hostname.  You will then want to choose “Configure Runtime Environments”
    4-9-2013 8-11-03 PM
  5. Add a new Tomcat environment, pointing to the Tomcat installation directory to where you unzipped Tomcat.
  6. Chose Next to add your new project to the server (other known as a resource).  Hit Finish.  Tomcat and Railo should now start.  You can watch it start by checking out the console view on the bottom of the screen.
  7. Within about a minute or so, you should see a new tab open up with the “Welcome to Railo” or “Welcome to CF” screen.  You server is now running.  You can check it out at http://localhost:8080/<projectname&gt;.
  8. As you place and save files in the WebContent directory, those files will be “published” to your local Tomcat server.  It sometimes takes a few seconds for them to be published.  You can always check the status by looking at the “Servers” view (this is a different Servers view that is just for CF server — this would be the Java one, which is usually hidden by default in CF Builder).
  9. Do note, this environment should be exactly the same as what is published out to Amazon Web Services — except it will be deployed in the Default context — which means that you won’t have the project name in the url. You will have something like  http://myproject.amazonwebservices.com/index.cfm   instead of  http://localhost:8080/myproject/index.cfm

Publishing to Amazon Web Services via Elastic Beanstalk

  1. So, you’ve got your environment setup, your project humming long locally, and you are ready to bring it to the web…  
  2. Right click on your project, go to Run As -> On Server.4-9-2013 8-20-45 PM
  3. Click on Manually Define a new Server, and choose “Amazon Web Services -> AWS Elastic Beanstalk for Tomcat 7″.  Click Next.
  4. Fill out the Elastic Beanstalk configuration form.  You will need to choose a region to launch the app at, an application name (this is used so you can identify your application), and an environment name (this becomes the prefix to the domain name that will be assigned to your application).  For this example, the domain assigned to the app was http://appDomainName.elasticbeanstalk.com.  Most likely you will point your own DNS entry to this.4-9-2013 8-25-46 PM
  5. Click Next.  This will allow you to choose which applications you want to deploy to the EC2 instance.  You will only have one, so hit Finish.
  6. Your application will be packaged as a WAR file, uploaded to S3, a new EC2 machine will be created, a firewall, load balancer and your app will be deployed.  This can take up to 10 minutes the first time.  If you get an error message stating the server took to long to launch, don’t worry…  It will launch.  It does take a while to start up the first time, trust me.
  7. After the app has launched, you should see an Elastic Beanstalk configuration screen.  This will allow you to tweak configuration settings, see the final URL, and much more.  Check it out.
  8. Modify the Start timeout setting under Timeouts to something large like 600 sec, so you don’t see any errors while deploying incremental updates.
  9. Congratulations!  Your CFML app is now on the web!

Check out Part 2 here.  I covered updating your application, integrating it with a database, using the administration interface and a discussion about licensing concerns.  

An Intro to ColdFusion Builder

ColdFusion Builder was released yesterday, and in all honesty I’ve been using it for about 6 months now (public and private betas).  It’s been rock solid and chalk-full of features, even for a 1.0 release.  Adobe also realized that they can’t make every feature available for the 1.0 release, so they made the entire thing extremely extensible.  But they didn’t just make it extensible, they made it extensible with ColdFusion / CFML code!  Now anybody can enhance the IDE to their liking.

Check out my screencast on how to do the basic setup of ColdFusion Builder.  More screencasts to come shortly about some of the cool features, like how to use the extensions :

ColdFusion Builder Introduction

Welcome to the family, Flash Builder 4!

This morning Adobe’s Flash Builder 4 and ColdFusion Builder 1.0 were released!  I feel like both have been in beta for ages and ages, but that’s most likely because they’ve been stable so long, and the world has been using it for at least the last six month.

So, what’s so great about Flash Builder 4? Lots and lots.  This 4th generation IDE really strives to make our (developers) lives better by making the work flows faster and better.   One of the biggest updates is the inclusion of the “DCD” or Data-Centric-Development work flow.  Flash Builder 4 abstracts all of the work that went into connecting Flex to database or back-end server like PHP or ColdFusion.  In mere seconds you can populate a datagrid from a web-service or AMF based PHP/ColdFusion code without worrying about all the connecting code that went into it.  And the code that is generated is not sloppy, template laden crud we would expect to find, but rather a best-practices implementation that is extendable to match how you are coding today.  DCD also allows for some of the features that were difficult to implent without the help of LCDS in the past like publishing the changes back to the database, data paging, etc.

Below is a quick screencast I made detailing the DCD workflow in Flash Builder 4:

Introduction to Data-Centric Development in Flash Builder 4

I will be posting more tutorials soon on some of my more favorite features of FB4, and ColdFusion Builder.  This is truly an epic release and I’m glad I was able to be able to work it in its final release :)

Follow

Get every new post delivered to your Inbox.

Join 27 other followers