CFDJ Feature — It Is Possible!

Now that Scorpio is here (at least in beta), it is time to start figuring out all the new tricks of the trade, right? However, as most of your clients will not be switching immediately, you will still have to be doing ColdFusion 7 work for some time.

How do you run both ColdFusion 7 to support your current clients and ColdFusion 8 to keep your development skills sharp? You could run one using the built-in Web server, but that's not really the same as your production systems. Instead, let's take a look at using the multiserver configuration option to run both CF7 and CF8 instances simultaneously and under your choice of Web server. The problem is, the system requirements for CF7 and CF8 are not compatible with each other, right? Yes and no...it's not quite out of the box, but it is possible to have complete working copies of each, running in complete parallel. The key is using the multiserver configuration and the JVM config.

ColdFusion Multiserver Configuration
For those who have never worked with the multiserver configuration (myself included until a few months ago), what is it? During the installation process for ColdFusion, the installer prompts you to select a server configuration option (see Figure 1). There are three options: single server (default), multi-server, and J2EE deployment. The single server option allows you to install a single copy of ColdFusion on your development workstation and connect it to your Web server of choice. This was always the route I took and I expect many did as well.

The J2EE deployment option gives you the ability to set up ColdFusion as an EAR or WAR file that can then be deployed to a Java application server such as JRun or Tomcat. If this went straight over your head, you probably need to know more about Java servers and this option won't be a lot of use to you - who needs a Java server if you can use the single self-contained server option, right?

The second option - multiserver deployment - is the one we are going to look at here. This option installs a full copy of Adobe's JRun 4 application server and then installs an instance of ColdFusion as a Web application on that Java application server. Adobe has set this up so that you can manage the different server instances deployed (including ColdFusion) through the ColdFusion administrator and never have to log into the JRun administrator. This is very nice for those of us who don't want to or don't have the time to become Java application server experts.

What Multiple Instances Give You
There are many benefits to setting up ColdFusion in a multiserver configuration. By going this route, you can deploy multiple instances of ColdFusion on the same server - hence the "multi-server" configuration. There are many benefits from a production standpoint including adding additional security between applications in the form of sandboxes and fine-tuning the JVM settings to boost the performance of different applications.

From a developer's standpoint, especially on our own development workstations, a multi-instance deployment of ColdFusion also provides several benefits. First, we can configure different settings including ColdFusion mappings and data sources for different applications. Have you ever had two applications that use the same framework but different versions? Both require the same mapping to be set up, but the mapping points to different file system locations. With a multi-instance deployment of ColdFusion you can put each application in its own ColdFusion instance, as you can configure the mappings and any other settings uniquely for each application.

The second and more important benefit in this case is that you can set different instances of ColdFusion to run using different JVMs. This is critical when trying to set up both ColdFusion 7, which only supports up to JVM 1.4.2, and ColdFusion 8, which will support JVM 1.4.2 but is better suited and performs better on the latest JVM (1.6).

The Install
Let's walk through the process of setting up a ColdFusion development workstation with both ColdFusion 7 and ColdFusion 8 deployed side-by-side. First a bit of background as to how I am putting together these instructions: my workstation does not have ColdFusion installed at all, so I am starting clean. Also, my workstation is running Windows Vista, so it already prefers the latest JVM, and, last, I am using IIS 7 for my Web server. This is not a big deal, although there are still a few issues regarding the JVM that we will walk through at that point.

Since I am running Windows Vista, I'm going to start with the ColdFusion 8 installer. You could easily do this process in reverse, but the ColdFusion 7 installer and Windows Vista don't play as nicely together as it is an "unsupported operating system." The first step is to run the ColdFusion 8 installer, agree to the license, and select the Developer Install (in my case). At this point, you will be prompted to select the installer configuration (see Figure 1).

For this install, select the multiserver configuration option. As mentioned previously, this will install a copy of Adobe's JRun 4 server, then install and deploy ColdFusion as a Web application on that server. By going this route, we can install an instance of ColdFusion 8 side-by-side with an instance of ColdFusion 7, which is our end goal.

At this point, the installation goes pretty much the same way as a single server configuration would. There are two things to take note of, however. When the installer asks for different path names (i.e., the CF Administrator location), remember that we will be installing both ColdFusion 7 and ColdFusion 8, which will utilize different CFIDE folders. My recommendation, and what has worked for me thus far, is instead of putting the CFIDE folder in c:\inetpub\wwwroot, put it in c:\inetpub\cfmx8root or c:\inetpub\cfmx7root. This way it is obvious later on which CFIDE folder belongs to which version.

The other thing to take note of is when the installer asks which Web site(s) to configure for use with ColdFusion. Again, in my case I am using IIS, so this may look a bit different based on your choice of Web server. With IIS, the installer gives you the option of installing to all Web sites, selecting one or more Web sites, or using the built-in Web server (see Figure 2).

On my first attempt, I selected "All IIS Websites" and this caused me quite a few headaches down the road. On my second attempt, I wised up and specified to only install and configure ColdFusion for the Default Web Site. By selecting this option, it's much easier to configure new Web sites down the road to communicate different instances of ColdFusion.

At this point, you should be good to go with the rest of the ColdFusion installation.

Your First ColdFusion Instance
When you log into the ColdFusion administrator after the installation, you should see a new menu item on the left-hand navigation menu called "Enterprise Manager" with a sub-link of "Instance Manager" (see Figure 3).

This screen is where you will add and remove instances of ColdFusion without having to use the JRun management console. Let's take a quick moment to look at the process of adding a new ColdFusion instance. First, click on the "Instance Manager" link under "Enterprise Manager." Then, click the "Add New Instance" button. You should see a screen similar to Figure 4 prompting you for information about the new instance/server.


In this form, you will need to specify a name for the server - this is the JRun server and will only be needed for recognition purposes so that you know which instance you are working with later. The server directory should be auto-populated as you enter a name for the server and my recommendation is to leave this as is.

At this point, we have no EAR or WAR file to use to create this instance, so leave that field blank. Since I am installing ColdFusion 8 on Windows Vista, I can go ahead and check the two check boxes to have a Windows Service set up to automatically start the ColdFusion instance upon boot. If you are installing ColdFusion 7 first on Windows XP, this should work as well. Click the Submit button and after a brief wait you should have a new ColdFusion instance ready to go. The acknowledgment screen should list some details about your new instance and give you a link to the ColdFusion administrator for that instance - remember, this is a completely separate instance with its own ColdFusion administrator. The next step is to connect this instance up to our Web server of choice - IIS 7 in my case. Adobe has helped us out here by including the "Web Server Configuration Tool." A shortcut to this tool should have been installed in your start menu. Selecting this option will show a command prompt window and a little Java window as seen in Figure 5.

To configure your Web server to work with your new ColdFusion instance, click the Add button. A new window will appear with a configuration form based upon your Web server setup. Using IIS, mine looks like Figure 6.

In the first section, you will want to select the JRun Server instance with the name you provided in the ColdFusion administrator when you created the new ColdFusion instance. In the second section, you'll want to select the Web site to which you wish to connect this JRun instance and then select the "Configure Web server..." check box in order to have all of the mappings, etc., set up. Last, click OK and the script should display some information in a command-prompt window before returning to the original Web server configuration window and showing the new ColdFusion instance. Just browse to the Web address associated with the selected Web site and you should be good to go. You have just created your first (officially it is your second instance as the default CF Administrator is running on an instance called "cfusion") ColdFusion multi-instance server configuration.

Your Second ColdFusion Instance
Now that we have ColdFusion up and running in a multi-instance server configuration, it is time (in my case) to get ColdFusion 7 set up. With Windows Vista, it can be a bit tricky to get the installer working, but what you need to do is run it with full administrative rights; to do this, right-click on the installer icon and select "Run as Administrator." Give it a few seconds and the installer should start up. As with the ColdFusion 8 install, the portions of the installer to focus on are the installation configuration and the default path names.

As before, agree to the license and select the developer edition for the ColdFusion 7 installer. This time, since we already have a Java Web server installed as part of the ColdFusion 8 install, we want to select the J2EE installation configuration option as shown in Figure 7.

What this option does is have the installer "deploy" ColdFusion as an EAR file that the JRun server, which was installed with the previous ColdFusion 8 install, will accept and turn into a working ColdFusion 7 server.

Like the ColdFusion 8 install, I chose to set the base installation path for ColdFusion and any associated add-ons (search, etc.) to C:\CFusionMX7 to make sure there is a difference between the ColdFusion 8 and ColdFusion 7 installs. During this installation, a new screen will present itself requesting the "Context Root." Since we are deploying this EAR to our local JRun server and wish it to behave as much as possible like the "standard" installation of ColdFusion, make sure this value is set to "/". This will set up the ColdFusion instance to respond to the root localhost address for your development machine. From this point on, the installer should look pretty familiar.

Deploying ColdFusion 7 to JRun
After the ColdFusion 7 installer completes, you should find a set of files at the installation path you provided (C:\CFusionMX7\ in the example). In this folder, you should find a file named "cfusion.ear". This is your ColdFusion 7 installation that now needs to be deployed to the previously installed JRun application server. To do this, we can utilize the same interface in the default ColdFusion administrator that we used to create a new instance of ColdFusion 8. Simply select the "Instance Manager" option under the "Enterprise Manager" option on the ColdFusion Administrator page as shown in Figure 8.

Specify a server name and path as you did before, but when you get to the EAR/WAR file field, insert the path to the "cfusion.ear" file that was generated during the ColdFusion 7 installation. By doing this, the instance manager will deploy the ColdFusion 7 instance to the JRun server instead of the default ColdFusion 8 instance.

Last, for a ColdFusion 7 instance, you do not want to select the check box to have the instance manager create an NT service for this instance. We will do that manually as there are a few things that need changing in order to get ColdFusion 7 to start properly. Now, click the Submit button to add the new ColdFusion instance and we'll almost be finished. This will be the same process that is followed every time a new instance of ColdFusion 7 is deployed, using the same cfusion.ear file each time.

Last, the JVM
JVM is short for Java Virtual Machine and is one of those little Java components that is necessary for ColdFusion or most any Java application to run. The problem we have is that by installing ColdFusion 8 first, any other application set up on that same JRun server will by default use JVM version 1.6. While this is perfect for ColdFusion 8, ColdFusion 7 does not support a JVM version above 1.4.2.

To get around this, first download and install JVM 1.4.2 separately from the Java Web site (http://java.sun.com/j2se/1.4.2/download.html). In this case, you'll need to install the full SDK and not just the JRE as ColdFusion relies on server components of the library that are not part of the JRE. Once the 1.4.2 version of the JVM is installed, we can use it to run the ColdFusion 7 instances.

To set up JRun to utilize the different JVM, navigate to c:\JRun4\bin and find the jvm.config file. Make a copy of this file (jvm_cfmx7.config) and then open it in your favorite text editor. At the top of the file, there should be a line that starts as "java.home". This line should be changed to read "java.home=c:/j2sdk1.4.2_14/jre" with the path pointing to the location where the 1.4.2 version of the JVM was installed. Save the file and then we need to use this file to configure the new ColdFusion 7 instance.

Remember, during the process of adding the new instance, the check box to create the Windows Service was left blank. This is intentional as by default each instance will use the version 1.6 JVM. However, Adobe has included a command-line utility to create a Windows Service and, using that utility, we can instruct the service to use the new jvm_cfmx7.config file and settings that we just created. The command-line utility string should look something like this.

c:\jrun4\bin\jrunsvc.exe -install [JRun Server Name]
"Adobe ColdFusion 7 AS [JRun Server Name]"
"Adobe ColdFusion 7 AS [JRun Server Name]"
-config [JVM Config File Name]

This command will create a new Windows Service that upon system boot will start the JRun server specified and use as its configuration the customized JVM config (jvm_cfmx7.config) file created earlier.

The last step to getting the ColdFusion 7 instance working is to set it up with your chosen Web server. There is a problem here because the Web Site Configuration Tool may work or may not again because of the JVM version discrepancy between ColdFusion 7 and ColdFusion 8. There is another command-line script that will take care of the configuration automatically and could easily be bundled with the above script for setting up the Windows service.

c:\j2sdk1.4.2_14\jre\bin\java -jar c:\jrun4\lib\wsconfig.jar -server
"[JRun Server Name]" -ws iis -site "[IIS Web Site Name]" -coldfusion -v

This command, launched using the 1.4.2 JVM version, will add the Web site connectors to the IIS Web site with the specified name, attach it to the JRun server with the specified name, and set it up for ColdFusion 7.

The Ultimate Development Workstation
At this point, you should have a working ColdFusion 8 instance side-by-side with a working ColdFusion 7 instance. If you need additional instances, they should be very simple to set up. Additional ColdFusion 8 instances are created using the default ColdFusion administrator and the Web Site Configuration Tool. Additional ColdFusion 7 instances are created using the default ColdFusion administrator, the cfusion.ear file, and the two command-line scripts mentioned earlier.

Hopefully, this will allow you to benefit from some of my hours of frustration and allow you to have a dual-CF development box that is easy to use and learn on at the same time.

© 2008 SYS-CON Media