Showing posts with label coldfusion. Show all posts
Showing posts with label coldfusion. Show all posts

Monday, July 02, 2012

Displaying PDF Form Fields Using iText and ColdFusion

One of my most recently developed web application is a new health care system for a number of laborites that perform various testing. The initial workflow has the central office receiving the lab test order and sample, entering it into the system, and then sending the sample and five or six (depending on the test ordered) worksheets along to the lab techs. Currently the worksheets that have to be completed are a variety of MS Excel, MS Word and an Adobe PDF file. This can take anywhere between 3 to 8 minutes to complete, depending on which forms are needed and what information is available on the test order. They asked for an easier way to do this.

I decided to explore generating a single PDF file that would be generated after the test order is entered in the system. The fields on the various documents that normally the administrative staff have to fill in would be populated by the web application. Normally this would be easy to do using cfpdfform, however for this project we’re using Railo instead of Adobe ColdFusion and the cfpdfform tag isn’t available. I was hoping that Railo 4 would include this tag as a feature, but there was no mention of it being included at cf.Objective() 2012 by the Railo team when I asked. I’ve asked on the Railo list twice, initially they said yes but most recently they haven’t responded. Therefore I needed to find an alternative solution, which I did, and here’s what I ended up doing.

Create a single Adobe Acrobat PDF Form

The first step was to use Adobe Acrobat Professional to combine the MS Excel, MS Word and Adobe PDF files into a single PDF file. The next step was to create the form fields within the PDF for the web application to populate from the database. Since every page had a “name” field, we just made that field name the same on each page.

Get iText

iText is a Java component that is designed to work with PDF files. It can create, read and update PDF files. The technical documentation on the website is pretty thin, they really encourage you to buy a copy of their “iText in Action” book. I’d have no problem with this, but they don’t currently offer a Kindle version yet so I’m holding off on that. I did find the API documentation is available online that you can use, and they do have the samples from the book available for download that may help.

Download the iText PDF community version from here. I decompressed these files and placed them in the same directory as I had my Railo JAR files, then I restarted Apache Tomcat. I’m pretty sure I could put these in my ColdFusion on Wheels application directory /lib directory and load them using the javaLoader for CFWheels, but I haven’t tried it yet.

CFDump the form fields

The next thing I wanted to do was to dump the form fields from the PDF file to make sure I was able to read the file correctly. I placed the single PDF file that we had created with all of the form fields with my ColdFusion on Wheels application directory. I then created a CFML page and used the following code to dump the form fields that are found within the entire file.


readPDF = expandpath("the_file_name_here.pdf");
writePDF = expandpath("#createUUID()#.pdf");
fileIO = createObject("java","java.io.FileOutputStream").init(writePDF);
reader = createObject("java","com.itextpdf.text.pdf.PdfReader").init(readPDF);
stamper = createObject("java","com.itextpdf.text.pdf.PdfStamper").init(reader, fileIO);
pdfForm = stamper.getAcroFields();


This dumped out a list of all of the form fields within the PDF so I can make sure that iText was able to read them, and that I spelled them correctly.

Populate the Form Fields

The next step was to populate these fields with data from my database. I also wanted to display this PDF in the users browser. I was able to to this pretty much as I did above, but just with a minor changes.


readPDF = expandpath("the_file_name_here.pdf");
writePDF = expandpath("#createUUID()#.pdf");
fileIO = createObject("java","java.io.FileOutputStream").init(writePDF);
reader = createObject("java","com.itextpdf.text.pdf.PdfReader").init(readPDF);
stamper = createObject("java","com.itextpdf.text.pdf.PdfStamper").init(reader, fileIO);
pdfForm.setField("date_sample_collected", "#date_sample_collected#");
pdfForm.setField("patient_name", "#patient_name#");
pdfForm.setField("date_of_birth", "#date_of_birth#");
pdfForm.setField("order_number", "#order_number#");
stamper.setFormFlattening(true);
stamper.close();
reader.close();
fileIO.close();


Summary

Using this code I was able to satisfy the initial request that the administrative staff, to save them from creating these additional forms manually with the data they had just entered into the web application.

I know I can make this better though, since not every page of that PDF is needed, it depends on the test selected. I plan to re-factor this application code in the future to to determine which test was selected, then only grab those worksheets. This means I’ll need to separate each of the worksheets out into a separate PDF file, then stitch them together, depending on what the user has entered for the order, into a single file.

Thanks To

Thanks to this cfSearching blog post that helped, as well as rip747’s Stackoverflow posting that helped me complete this task.

Sunday, December 11, 2011

Beating the Flying Spaghetti Code Monster with CFWheels - Part 2

Beating the Spaghetti Code Monster

Recap

As I mentioned in part 1 of this post, when I started writing web applications with ColdFusion I quickly amassed a large collection of autonomous files that would often break if I changed a variable or parameter that should be passed into the next. Adding or removing a column to a form / database table could take 25 minutes to update all of the SQL files. I had become enslaved to the “Flying Spaghetti Code Monster”, as I like to call it, and knew there was a better way and wanted to find it.

The Application

As I also mentioned in part 1, I had been re-hired to maintain and update a web application I wrote 7 years prior. This application had well over 350 individual files and the folder size was near 80MB. Although I had started to use the Fusebox framework, which helped start to organize my files, I didn’t follow-through on converting everything to Fusebox. This meant that my directory structure looked something like this
Spaghetti Code Directories

Conversion

As also mentioned in part 1 of this post that I decided to slowly convert the application to the Coldfusion on Wheels framework. I decided to do this cutting off one “tenticle” at a time, or one section/feature at a time.
First I identified a small section of the application that I could replace with the CFWheels framework. I selected one of the “system options” that allows users to add new values to a drop-down list of patient types. The code for this was located off the root of my application in a /system folder along 15 other similiar system options that were almost identifcal. I also needed a place to put my CFWheels core files.
I decided to put the CFWheels framework files in a directory named “hla”, which is the web application name as referred to by the staff, under the /system folder, so /system/hla/
CFWheels framework location
I setup my database connection info in the /conf/settings.cfm file so that my database connection would be the same as the spaghetti code portion. Next, I didn’t want to have two sets of Javascript, CSS or other asset files like images, so I had to modify my CFWheels layout.cfm file to reference the ones that the spaghetti code files were using.
layout.cfm
At this point I could browse to the CFWheels portion, by manually entering the URL, and receive the default CFWheels welcome page. I then added a new entry on my system options menu to point to the new CFWheels location where the system option I was going to convert would live.
At this point I created a model file, Patiettype.cfc, and in the init function I added code to specify my database table names that didn’t follow the Wheels convention, but were used by the Spaghetti Code application
<cfset table("tbl_authors")>
Next I followed with each database table column as a property, using the current database column name for the column attribute but a CFWheels convention name for the name attribute, as outlined in the CFWheels documentation.
<cfset property(name="firstName", column="tbl_auth_f_name")>
These system options required that I setup some associations, and this was a great place to learn about that as I’d need it for every other part of the application.
At this point I could follow the CFWheels conventions and develop the CRUD for the Patienttype just like I would a brand new CFWheels app. After I have the CRUD working for this system option, I’d then remove the link to the old files and leave just the new one. Then I’d have the users work with that section for about a week. Once we were sure everything worked correctly, I’d slowly remove the old files (that I now had in Git version control).
Using this same method I slowly worked through all of the 16 system options, as if cutting off one “tenticle” of the Spaghetti Monster at a time. After I finished with those small, simple CRUD actions, I moved onto more complicated sections. The whole Contacts portion, then Hospitals portion, etc.

Progress

I found the Coldfusion on Wheels framework in February 2011, then started implementing it in March 2011, working part-time and slowly through each of the tenticles I mentioned. If new features were requested, or something needed to be changed, I fought the urge to do a “quick and easy” one or two file solution and forced myself to do it the CFWheels way. At first this was challenging, but once I got use to it, the changes happened faster.
At this point, December 2011, I’ve removed at least 23 of these “tenticles” with two medium sized tenticles and one large tenticle left to remove from the monster. I’m excited to finish these sections off and sever the head of this monster once and for all. In hindsight I’m glad I started with smaller tenticles as it allowed me to learn CFWheels with smaller sections of code, but also to find “gotchas” early on.

Gotchas

One of the things I didn’t expect was the Spaghetti Monsters session scope being overwritten when I moved went to a CFWheels framework page. This made it a little tricky because I’d use the session scope to retain the currently logged in user ID and if they were a valid user or not (to prevent unauthorized access). After I’d leave a CFWheels page and go back to the Spaghetti Monster code I’d be kicked out of my application. My “fix” for this, at least for the time being, was to use client variables for the Spaghetti code portion of the application and session variables for the CFWheels portion of the application.
The next thing I ran into, since my session scope was being overwritten, was once I moved to a CFWheels portion of the application I’d didn’t have my session variable with the user ID from the Spaghetti Monster code. To fix this I added an obtuse URL variable on the menu links in the Spaghetti Monster code that CFWheels would then use to identify the user and create the session scope variables I wanted.

Summary

I feel converting this application to the CFWheels framework has helped with the following:
  1. Brought some sanity back to how this application is structured and maintained (huge benefit)
  2. Saved gobs of time not having to maintain query files with endless CFIF statements and cfqueryparam tags (CFWheels ORM does that all for me, huge benefit)
  3. Made the application run faster, I mean noticably faster to my users
  4. Decreased the code folder from 80MB to 33MB
  5. Allows me to add new features or make changes in less time then before because things break less when changes are made
  6. Allows anyone that knows about the MVC pattern to help or take over this application
  7. Made Coldfusion programming fun again (most important of course)
While converting this application from the Spaghetti code to the CFWheels framework from “the inside out” has been a slow process (because of my, not the framework), I don’t regret doing it at all for the reasons stated above. It’s been a great way to learn CFWheels and to work with the CFWheels community. At this point I can’t imagine developing Coldfusion applications without using the CFWheels framework.

Thursday, December 01, 2011

Beating the Flying Spaghetti Code Monster with CFWheels - Part 1

Flying Spaghetti Code Monster

Background

I started writing web application using Coldfusion in 2000 with version 4.5. Like probably most of us back in those early days, we had one hand on the keyboard and a copy of Ben Forta’s Web Application Contrution Kit (WACK) in the other. My development of applications consisted of creating a single autonomous file, with both database queries and conditional display code. This of course was tied to yet another autonomous which did the same, etc, etc, etc. Thus the “Flying Spaghetti Code Monster” Even after I started to use the Application.cfm “framework” within ColdFusion, I still had all of these autonomous files that would often break if I changed a variable or parameter that should be passed into the next.
After developing a few applications like this I realized there had to be a better way. Somehow I came across the Fusebox 2 framework and started to look into it. This framework encouraged you to break the application up into separate files, query file, action file, display file, and then “chain” these together like fuses in an electrical circuit.
Shortly after Fusebox version 3 was released and I begin using this framework to develop my applications. I especially loved the formurl2attributes function that put all of your url and form variables into a single scope. I started to convert small pieces of my existing applications from my spaghetti code to organized code following the Fusebox methodology, however I ended up sticking more with the file naming then actually using the framework after a while. When Fusebox version 4 was released I found it difficult to grasp, as well as the CFC concept that was brand new. My two and a half years of part-time web application programming was coming to a close though as I left to work full-time as a systems administrator.
Over the next 7 years the largest of the web applications I wrote, a Laboratory Information System (LIS), continued to work for the University lab I wrote it for with minimal adjustments to it.

Back to Developing

At the end of those 7 years I was hired back, part-time, for this same lab, and part-time for another lab (so it’s a full-time position) on campus. When I looked at this old source code I saw the “Flying Spaghetti Code Monster” glaring back at me. I had well over 350 individual files and the folder size was near 80MB, not to mention no source control software to help manage it. I knew there had to be a better way to handle this, I didn’t want to continue to develop this way.
The first thing I did was get the software into a source control system. Subversion was the choice as it was the easiest for me to grasp initially. I went back to look at the Fusebox framework and saw it was still around, but it didn’t seem like many were using it any longer. There was the Mach-II framework, but I couldn’t seem to understand that either. In the meantime I continued to serve the hard master known as the “Flying Spaghetti Code Monster” and maintain the code as it was, even adding new features, without much difference in my development pattern.
After five months of developing this way I came across the ColdFusion on Wheels framework website, not sure how (probably Twitter). After greedily consuming all of the available screencasts I knew this was the way I needed to develop the application. The question was, how do I learn the CFWheels framework and use it to power this application? I saw two choices:
  1. start from scratch in a parallel environment using CFWheels and recreate all of the functionality
  2. slowly, one “tenticle” at a time, battle the “Flying Spaghetti Code Monster” by converting a section to the CFWheels framework
After considering it I decided choice 2 was for me, to slowly convert the application. In the following post I’ll explain how I’m doing this.

Wednesday, October 12, 2011

Changing Fonts in Sublime Text 2

I’ve been using the Sublime Text 2 app for this past week and really like it. One of the things I wanted to change though was the font used in the editor. A font I’ve liked in the past was Consolas but I couldn’t find that. I did find one named Inconsolata, which is almost identical from what I can tell, on Google Web Fonts. Here’s how I set everything up on my Mac

Get the font(s)

  • Head over to Google Web Fonts and search for “Inconsolata”, or any other font that you like (other suggestions are Ubuntu Mono or Varela Round)
  • Click the “Add to Collection” button to the far right of the font name
  • Click the “Download your Collection” link on the top-right.
  • Click the “Download the font families in your Collection as a zip-file” link on the pop-up dialog
  • Open the zip-file that’s downloaded
  • Double-click on each .ttf file
  • Select to “Install Font”

Configure Sublime Text 2

  • Open Sublime Text 2
  • Click on the “Sublime Text 2” application menu
  • Select “Preferences”
  • Select “File Settings - User”
  • In the file that opens, add the following line along with the name of the font you installed:
    "font_face": "Varela Round"
    Be sure to include a comma “,” if you’re adding this to a line already within the file, like a color scheme selection.

You can also change the font size using the following:

"font_size": 16
Notice that the number for the font size isn’t in quotes. Once you save the file you should see the results immediately as the configuration file you’re working in is redrawn using your selections.

Here’s my current complete configuration file

{
    "color_scheme": "Packages/Color Scheme - Default/Indy Merbivore Soft.tmTheme",
    "font_face": "Varela Round",
    "font_size": 16
}

Three New Sublime Text 2 Features

Here are three new Sublime Text 2 features that I learned today, thanks to this article at Net tuts+, that I feel really put it high on my list for a ColdFusion editor.

  • Function Crawling - while working within a CFC I press Command + R on my Mac and I now have a list all of functions within that component with my cursor focused in this box. I start typing the function and press enter to quickly jump to it. Awesome!
  • Command Palette - while working within a CFML page I press Shift + Command + P to have the entire list of snippets (i.e. cfml tags and functions) that I can start typing to find and press enter (sometimes I forget the exact name so this really helps).
  • Lightning-Fast File Switching - while working in a file I press Command + P and now have a list of the files with in the project I’m working in. I start typing the file to have it opened for me, I don’t even have to press Enter

Using Sublime Text 2 as ColdFusion Editor

I’ve tried a lot of different editors for writing my ColdFusion code, but never found one that really worked well for me until now. Now I think I’ve found the one that works best for me, Sublime Text 2.

In the past I’ve tried:

  • Coda by Panic = does a really good job with handling the auto-completion of quotes and parenthesis. Has tabs for multiple file editing and does CSS, has a web preview and a Terminal tab. It’s a Panic app, which has a tradition of working really well. However I started to run into these I’d really like, like code folding, easier code colouring and speed seemed to decrease with each release. Coda 2 is “in the works”, but no one really knows when it’ll show up.
  • CFEclipse = I like how extensible the Eclipse platform is, it’s much more of a Integrated Developer Environment (IDE) then Coda. With extensions like Subclipse (Subversion), eGit (GIT) and Mylyn, it can be a pretty sweet tool. However like any Eclipse based environment that I’ve used it suffers two serious problems that over-time frustrate me. It seems to get slower and slower, and the way that it auto-completes of quotes and parenthesis easliy gets confused.
  • ColdFusion Builder 2 = same as CFEclipse, except it costs money to run slow, and if I’m correct in what I’ve found, only runs in 32-bit mode and not 64-bit mode in Mac OS X.
  • TextMate = from what I’ve read this application is pretty “long in the tooth”, but it seems to have a good sized and very faithful following. There is a ColdFusion bundle available. It’s very fast, you can define projects to see all of the code in your directories and has tabs. It works very well with the auto-completes of quotes and parenthesis. TextMate charges for a license, which I paid, but I just had a hard time getting into how to use it and didn’t find much in the way of documentation or screencasts that explained it well to me.

Sublime Text 2

I’ve been using a beta copy of the Sublime Text 2 editor for the Mac and really like it so far. Some of the key things I like about it after a week are:

  • It’s fast
  • Auto-completes the use of quotes and parenthesis correctly.
  • Good code syntax colouring, that can be modified, although I’m using the “Merbivore Soft” theme by Indynagpal.
  • Can open a folder so I can see multiple files at once
  • For file contents that are taller then the screen, a “code overview” of sorts displays on the right to quickly jump to another locatio in the file.
  • Code-folding
  • Tabbed interface for files, and interestingly when you click on a file it will show the contents but not open it as a tab unless you start to edit the file or double-click on it, great for a “quick peek” of the contents!

As I work with Sublime Text 2 more, and as it evolves from it’s beta form, I’ll post more on how I’m using it and what I find benefical.

Friday, July 01, 2011

Coda book for CFWheels // Stofke on wheels

This is a great reference tool for looking at the ColdFusion on Wheels framework documentation within the Coda web editor from Panic

Friday, May 20, 2011

Setting Up a Mutli-CFML Engine Development Server

Summary

After attending the cf.Objective() 2011 conference last week, and attending Matt Woodward’s “Running Mulitple CFML Engines on Apache Tomcat” session, I wanted to setup a development server running multiple versions of the CFML language.  I decided to setup this server with the following technologies:

I’m sure I’ll repeat this process at some point in the future so I wanted to record these steps to simply the process in the future, and perhaps someone else might find them helpful.  Note that I’m installing all of this in a virtual machine on my Mac using VMware Fusion, however you should be able to do the exact same thing using VirtualBox.

Install Ubuntu Server

  1. Download the server ISO and install this in your virtual machine
  2. Accept all of the default options and make sure you select the “OpenSSH” option when prompted near the end.
  3. We need to modify the packages source for one of the components required for ColdFusion, so open the sources list by typing
    nano /etc/apt/sources.list
  4. Add the following line as the first line under “universe” packages
    "deb http://us.archive.ubuntu.com/ubuntu jaunty main universe"
  5. Now we’ll install some additional packages that are needed for the guest tools by your virtualization software and ColdFusion, as well as upgrade the server software to the latest versions by typing
    sudo apt-get update
    sudo apt-get install build-essential gcc linux-headers-$(uname -r) libstdc++5 
    sudo apt-get upgrade 
    sudo apt-get dist-upgrade"
  6. Determine your virtual machines IP address by typing “sudo ifconfig” and recording the 192.x.x.x address as you’ll need later.
  7. Install the VMware Tools or VirtualBox Guest Additions for best performance.  If you’re on VMware Fusion you’d type the following:

    sudo mkdir /mnt/cdrom
    sudo mount /dev/cdrom /mnt/cdrom
    ls /mnt/cdrom
    tar xzvf /mnt/cdrom/VMwareTools-<x.x.x-xxxx>.tar.gz -C /tmp/
    cd /tmp/vmware-tools-distrib/
    sudo ./vmware-install.pl -d
    sudo reboot
    

    Install Apache HTTP Server

    • Install the Apache web server by typing “sudo apt-get apache2”
    • Browse to http://<server_ip_address_here> to verify the installation is successful and running

    Install MySQL Client & Server

    • Install the MySQL client and server by typing “sudo apt-get mysql-client mysql-server”
    • Set the root password when prompted

    Install Oracle Java

    • Download the latest Java JDK, make sure to NOT select the one with the “RPM” in the file name, you do NOT want that file.
    • Copy this file to your virtual machine.  If you’re on a Mac you’d use Secure File Copy to do this by opening your Terminal, then going to your Downloads directory (type “cd Downloads”) then type
      scp jdk<full file name here> <ubuntu_user_name_here>@<ubuntu_ip_address_here>:~
    • Login to the Ubuntu server
    • Make the Java package executable by typing
      sudo chmod +x jdk<full_file_name_here>
    • Execute the Java package by typing
      sudo ./jdk<full_file_name_here>
    • Make a general java directory for holding the Java VM for the system by typing
      sudo mkdir -p /opt/java
    • Copy the Java installation to the /opt/java directory by typing
      sudo cp jdk<full_file_name_here>/ /opt/java/
    • Now we need to add the Java path to the environment variable for easy access.  It’s important to note the actual directory name created for your version of Java as it maybe different then mine.  My entire path is /opt/java/jdk1.6.0_25/
    • Modify your environment variables by typing
      sudo nano ~/.bash_rc
    • Add the following lines:
      PATH=${PATH}:/opt/java/jdk1.6.0_25/bin  #you'll need to change if your directory name is different
      export PATH
      JAVA_HOME=/opt/java/jdk1.6.0_25  #you'll need to change if your directory name is different
      export JAVA_HOME
      
    • Now exit the editor by holding down the Control key and pressing the “X” key, type “Y” to save and then the Enter key to retain the same file name.
    • Restart your server

    Install Apache Tomcat 7

    • Download the latest .tar.gz file
    • Copy this file to your virtual machine.  If you’re on a Mac you’d use Secure File Copy to do this by opening your Terminal, then going to your Downloads directory (type “cd Downloads”) then type
      scp apache-tomcat<full_file_name_here>  <ubuntu_user_name_here>@<ubuntu_ip_address_here>:~
    • Extract the Tomcat archive by typing
      tar -xf apache-tomcat<full_file_name_here>
    • Delete the archive by typing
      sudo rm -rf apache-tomcat<full_file_name_here>
    • Now we’ll rename the directory to make it easier to reference by typing
      sudo mv apache-tomcat tomcat
    • Move the Tomcat program to the /opt directory by typing
      "sudo mv tomcat /opt
    • Now we need to modify the environment for Tomcat, to do this type “sudo nano /opt/tomcat/bin/setenv.sh” and add the following two lines for your environment
      export JAVA_HOME=/opt/java/jdk1.6.0_25
      export CATALINA_OPTS="-Xms256m -Xmx512m -XX:MaxPermSize=384m"
      
    • Now exit the editor by holding down the Control key and pressing the “X” key, type “Y” to save and then the Enter key to retain the same file name.
    • Start the Tomcat server by typing
      sudo ./startup.sh
    • Browse to http://<server_ip_address_here>:8080 to verify the installation is successful and running

    Install Open BlueDragon

    • Copy this file to your virtual machine.  If you’re on a Mac you’d use Secure File Copy to do this by opening your Terminal, then going to your Downloads directory (type “cd Downloads”) then type
      scp openbd.war  <ubuntu_user_name_here>@<ubuntu_ip_address_here>:~
    • Login to your Ubuntu Server
    • Deploy the Open BlueDragon engine by typing
      sudo cp openbd.war /opt/tomcat/webapps/openbd.war
    • Browse to http://<server_ip_address_here>:8080/openbd to verify the installation is successful and running

    Install Railo

    • Copy this file to your virtual machine.  If you’re on a Mac you’d use Secure File Copy to do this by opening your Terminal, then going to your Downloads directory (type “cd Downloads”) then type
      scp railo-<full_file_name_here>   <ubuntu_user_name_here>@<ubuntu_ip_address_here>:~
    • Login to your Ubuntu Server
    • Deploy the Railo engine by typing
      sudo cp railo<full_file_name_here>.war /opt/tomcat/webapps/railo.war
    • Browse to http://<server_ip_address_here>:8080/railo to verify the installation is successful and running

    Install Adobe ColdFusion 8

    • Copy this file to your virtual machine.  If you’re on a Mac you’d use Secure File Copy to do this by opening your Terminal, then going to your Downloads directory (type “cd Downloads”) then type
      scp coldfusion-8<full file name here>  <ubuntu_user_name_here>@<ubuntu_ip_address_here>:~
    • Login to your Ubuntu Server
    • Make the ColdFusion installer executable by typing
      sudo chmod +x coldfusion-801-lin64.bin
    • Start the installer by typing
      sudo ./coldfusion-801-lin64.bin
    • Select the following options:
      • Read through the license agreement by pressing the Enter key
      • For install type, select “Developer Edition” using #3
      • For installer configuration, select “J2EE configuration (WAR file)” using #4
      • Un-select all of the sub-components by pressing 1, Enter, 2, Enter, 3, Enter, 4, Enter, 5, Enter
      • For Choose Install Folder, press Enter to accept the default
      • For Configure ColdFusion with OpenOffice, select 2, Enter
      • Enter a password for the ColdFusion administrator
      • For Enable RDS, select Y
      • Enter a pssword for RDS
    • Now that the installer has completed, we need to deploy the ColdFusion 8 engine by typing
      sudo cp /opt/coldfusion8/cfusion.war  /opt/tomcat/webapps/cfusion8.war
    • Browse to http://<server_ip_address_here>:8080/cfusion8/CFIDE/administrator/index.cfm to verify the installation is successful and running

    Install Adobe ColdFusion 9

    • Copy this file to your virtual machine.  If you’re on a Mac you’d use Secure File Copy to do this by opening your Terminal, then going to your Downloads directory (type “cd Downloads”) then type
      scp ColdFusion_9_<full file name here>  <ubuntu_user_name_here>@<ubuntu_ip_address_here>:~
    • Login to your Ubuntu Server
    • Make the ColdFusion installer executable by typing
      sudo chmod +x ColdFusion_9_WWE_linux64.bin
    • Start the installer by typing
      sudo ./ColdFusion_9_WWE_linux64.bin
    • Select the following options:
      • Read through the license agreement by pressing the Enter key
      • For install type, select “Developer Edition” using #3
      • For installer configuration, select “J2EE configuration (WAR file)” using #4
      • Un-select all of the sub-components by pressing 1, Enter, 2, Enter, 3, Enter, 4, Enter, 5, Enter
      • For Choose Install Folder, press Enter to accept the default
      • For Configure ColdFusion with OpenOffice, select 2, Enter
      • Enter a password for the ColdFusion administrator
      • For Enable RDS, select Y
      • Enter a pssword for RDS

    Install Adobe ColdFusion 9.0.1 Update

    • Copy this file to your virtual machine.  If you’re on a Mac you’d use Secure File Copy to do this by opening your Terminal, then going to your Downloads directory (type “cd Downloads”) then type
      scp  ColdFusion_update_<full file name here>   <ubuntu_user_name_here>@<ubuntu_ip_address_here>:~
    • Login to your Ubuntu Server
    • Make the ColdFusion installer executable by typing
      "sudo chmod +x ColdFusion_update_901_WWEJ_linux64.bin
    • Start the installer by typing
      "sudo ./ColdFusion_update_901_WWEJ_linux64.bin
    • For the installer do the following:
      • Press Enter
      • Accept the license agreement
      • For Configuration Installation select #3
      • For EAR/WAR Location, enter the location you used in the previous installation
        • /opt/coldfusion9/cfusion.war
      • For the “Pre-Installation Summary”, press Enter
    • Now that the installer has completed, we need to deploy the ColdFusion 9 engine by typing
      sudo cp /opt/coldfusion9/cfusion.war  /opt/tomcat/webapps/cfusion9.war
    • Browse to http://<server_ip_address_here>:8080/cfusion9/CFIDE/administrator/index.cfm to verify the installation is successful and running

    Configuring Tomcat to startup with the system

    For one last bit of configuration, we’ll set the Tomcat server to start at system startup to make things easier for us.  To do this I’m going to borrow a script written by Aaron West here with a few mondifications following Jenson Taylor written here for my system.  To setup this file type the following

    sudo nano /etc/init.d/tomcat
    and then add the following to the contents:

    #!/bin/sh -e
    ### BEGIN INIT INFO
    # Provides: tomcat
    # Required-Start: $local_fs $remote_fs $network $syslog
    # Required-Stop: $local_fs $remote_fs $network $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # X-Interactive: true
    # Short-Description: Start/stop Tomcat as service
    ### END INIT INFO
    
    # setup the JAVA_HOME environment variable
    export JAVA_HOME=/opt/java/jdk1.6.0_25
    
    ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin"
    
    #set -e

    #. /lib/lsb/init-functions #test -f /etc/default/rcS && . /etc/default/rcS case $1 in start) echo -n "Starting Tomcat server" echo " " sh /opt/tomcat/bin/startup.sh echo ;; stop) echo -n "Stopping Tomcat server" echo " " sh /opt/tomcat/bin/shutdown.sh ;; restart) echo -n "Restarting Tomcat server" echo " " sh /opt/tomcat/bin/shutdown.sh echo " " sleep 6 echo " " sh /opt/tomcat/bin/startup.sh sleep 6 ;; esac exit 0

    Now we set this file to be executable and start at system startup by doing the following:

    cd/etc/init.d
    sudo chmod +x tomcat"
    sudo update-rc.d -f tomcat defaults"
    sudo shutdown -r now" to restart your server
    

    Now if you restart your system, the Tomcat server should come up automatically!