QueTwo's Blog

thouoghts on telecommunications, programming, education and technology

ColdFusion (Railo) on Microsoft Azure Websites with IntelliJ IDEA — Part 1

I was lucky enough to have Microsoft give me some time on Azure through the BizSpark program.  If you don’t know what BizSpark is, it is a program from Microsoft to give small businesses a headstart on the Microsoft stack, grattis for three years.  That includes MSDN, some credits on Azure and more.  Azure is a comparable solution to Amazon’s Web Services that I’ve been using for a few years.  Azure’s Websites solution is similar to AWS Beanstalk where you upload your final project to their servers and they take care of the rest (OS, patches, firewalls, etc.)

As I’ve already written in previous blog posts, Railo is simply a Java application that can sit on top of a J2EE server such as Apache Tomcat.  Railo is compatible with Adobe ColdFusion, and is 95% there for simply letting ACF code run.  The only time you can expect to run into issues is with some of the integration tags like CFEXCHANGE, CFCHART or some of the Active Directory integrations.  But on the flip-side, Railo requires no install, no purchase of a license, and (in my opinion) is easier to work with.

In this walk-through I’m going to use Railo 4.2.1 deployed as a WAR application onto Apache Tomcat running on Azure Websites and using IntelliJ IDEA 13.1 as my IDE.  You should be able to easily substitute Eclipse or ColdFusion Builder for the IDE — I just don’t happen to use those anymore.

Downloading all of the required components:

You will need:

Setting up your environment:

Do the following:

  1. Extract the Tomcat .ZIP file to a directory on your computer.  Doesn’t really matter where — as long as you know where it is.  This will be where your local, testing environment will run from.
  2. Rename the Railo .WAR file to .ZIP.  This will be the files you will start with.
  3. Install IntelliJ, if you haven’t already.
  4. Add your Tomcat setup to IntelliJ.

    1. Go into the IntelliJ Settings by clicking on Configure -> Settings from the Quick Start menu, and search for Application Servers under IDE Settings.
    2. Click the green [+] and then select Tomcat Server.
    3. Provide the Tomcat Home directory.  This is the directory where you extracted Tomcat to.
    4. Hit OK, then Apply to commit this new application server to IntelliJ
      intellijSettings
  5. Add a new Java Project to IntelliJ
    1. Go back to the Quick Start menu, and choose Create New Project
    2. Select Java and then Select Web Application.  You may need to add a new Project SDK by clicking on New… on the upper-left of the screen and letting IntelliJ know where your copy of Java is installed.
      new-project
    3. Don’t select to create the project from a template.  Click Next.
    4. Give the project a name and a location.  Click Finish to create the project.
      createProjectName
    5. After IntelliJ creates the project, in the Project area, you should see a src folder, a web folder, a JSP file, and a WEB-INF folder.
      project-view
  6. Test your application setup with Tomcat.
    1. From the “Run” drop down, select “Edit Configurations…”  to add a new run configuration.
    2. In the “Run/Debug Configuration” screen, click the [+], select Tomcat Server, then Local to add our run config.
      runconfig
    3. Give the Run Config a name (like “Local Debugging”)
    4. Click the “Fix” button near the error that states you don’t have an artifact marked for deployment.  This will tell IntelliJ that we plan on deploying our project to our local test server when we click the Run button.  The name of the base “artifact” is “SampleWebsite:war exploded”.
    5. Change back to the Server tab.  Change the option “On Frame Deactivation” to “Update Resources”.  This means that when you make a change within IntelliJ and switch to your web browser to check that change it will happen automatically.
    6. Click Apply then OK to close the window.
  7. Run the Local Application Server and deploy our base application.
    1. Click the green “Run” button next to the drop-down with the Run configuration we just created.  You will see Tomcat spin up in the console messages on the bottom of the screen.  Eventually you will see a browser launch with a blank page.  This is actually displaying the contents of the index.jsp file in our project.
  8. Copy Railo into our project.
    1. Remember when we renamed Railo to be a ZIP file?  Extract that ZIP file into our web folder within our project.  You most likely have to do this outside the IDE.  You will need to overwrite the WEB-INF folder (including the web.xml that is included within it).
    2. Delete the index.jsp file within the web folder.  You don’t need it anymore.
    3. Within the web folder, create a new file named index.cfm.   Add a <cfdump var=”#server#”>
      runCF
    4. Click on the green “Run” button next to the drop-down with the Run configuration we created earlier.  You will get a dialog asking if you want to update the resources or restart the server.  Chose “Restart the server” so that we can load Railo.  This is the same option you would use if you ever need to restart CF (for example, to unload a CFC that is loaded into the session memory).
      restartcf
    5. You will see Railo unpack and launch with the console window.  After a few seconds, you should see your browser launch with the debug output.  Congratulations, you are now running CF!
  9. Create your application like you normally would.
    1. Any files within the WEB folder of your project are essentially in the root of your web server.
    2. Railo Administration Dashboard (The CFIDE, if you will) is located at http://localhost:8080/railo-context/administrator/server.cfm    This is where you would setup your databases, etc.
  10. Copy your configuration files BACK to your project
    1. Any files that change on your web server are NOT copied back to your project.  This includes configuration changes (like databases) made within the Railo admin.  To copy these files back, go to your project folder (in my case E:\Projects\SampleWebsite), then OUT\Artifacts\SampleWebsite_war_exploded\    and copy all the files back to your project.  In my previous blog entries I mention which files you can copy back if you are simply looking to save the Railo config files.

Part 2 of this entry I will show how to get this posted on Microsoft Azure Websites.

Advertisements

One response to “ColdFusion (Railo) on Microsoft Azure Websites with IntelliJ IDEA — Part 1

  1. Pingback: ColdFusion (Railo) on Microsoft Azure Websites with IntelliJ IDEA — Part 2 | QueTwo's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: