Creating a ColdFusion MX 7 Flex JRun Instance

(this article was posted on the Flex Authority website)

Update May 18, 2008: The original Flex Authority site is long gone.  Additionally, this example is extremely outdated and no longer relevant.

This example uses Microsoft Windows Server 2003, Microsoft Internet Information Services 6.0, Macromedia ColdFusion MX 7 Enterprise Edition, and Macromedia Flex 1.5.

There are two ways to integrate Flex 1.5 on a ColdFusion MX 7 JRun server instance. The steps are almost identical, with one minor difference at the end. The easiest way to explain the necessary steps in their entirety is by describing the creation of a new CF server instance and integrating it with Flex on a non-default IIS website. This process will assume that ColdFusion MX 7 Enterprise Edition has already been installed in the multiserver configuration on JRun 4.

The first step is to create a new JRun server instance. This can be accomplished in the ColdFusion MX 7 Administrator. Log in to the CF Admin. Click the "Enterprise Manager" link at the bottom of the navigation menu and click the "Instance Manager" link.

Any JRun server instances that have been created, aside from the primary ColdFusion server instance created during installation, can be seen here. Click the "Add New Instance" button to begin.

For this example, call the new server instance CFFlex. In the "Server Name" text field, type CFFlex, then hit the TAB key. Notice that the "Server Directory" field automatically updates to be C:\JRun4/servers/CFFlex. This directory will be the server root of the new JRun server instance. In addition, a windows service must be created so that the server instance automatically starts when the computer starts up. Therefore, check the "Create Windows Service" checkbox.

Click the "Submit" button. The ColdFusion administrator will then go through an automated process to create, deploy, and start the new CF JRun server instance. When this process is complete, the page will display the following:

The next step is to install Flex. The Flex 1.5 installation file does not "install" anything in the traditional sense of the word. It extracts a number of files necessary to deploy the Flex web application onto a JRun server instance. Run the Flex 1.5 installation program on the server and choose all the defaults. When it comes to the installation options, be sure to NOT select the "Flex with integrated JRun option."

When the installation is finished, a number of files will be extracted to C:\Program Files\Macromedia\Flex, including the file flex.war.

Although flex.war is a packaged J2EE web application, for this example the file must be opened and the contents extracted with any zip utility. With this being said, extract the contents of flex.war to a temporary directory such as C:\flextemp.

Copy the entire \flex directory from C:\flextemp\WEB-INF:

to the \WEB-INF directory of the new ColdFusion server instance. It should be found at: C:\JRun4\servers\CFFlex\cfusion.ear\cfusion.war\WEB-INF.

Next, copy flex-bootstrap.jar and flashgateway.jar from C:\flextemp\WEB-INF\lib:

to C:\JRun4\servers\CFFlex\cfusion.ear\cfusion.war\WEB-INF\lib.

The files commons-beanutils.jar and commons-collections.jar should already exist here. If they do not, copy them to the same location.

The next step involves merging the web.xml files from the ColdFusion server instance and the C:\flextemp files. Make a copy of your existing ColdFusion web.xml file before proceeding in case the need to start over arises. Open the following two files:

C:\JRun4\servers\CFFlex\cfusion.ear\cfusion.war\WEB-INF\web.xml

and C:\flextemp\WEB-INF\web.xml.

Copy the child nodes from the Flex file to the ColdFusion file. The root node of both web.xml files is . The first two child nodes are and . It is not necessary to copy these two nodes, but copy all child nodes following the node from the Flex file to the ColdFusion file. According to Macromedia, the nodes copied from the Flex file must be placed at the end of each group of nodes in the ColdFusion file. For clarification, please follow the example below.

Copy all the nodes from the Flex web.xml file to the ColdFusion web.xml file immediately following the existing nodes in the ColdFusion file. Note the table below.

ColdFusion web.xml - destination Flex web.xml - source

#tab#cf.class.path
#tab#...


#tab#cf.lib.path
#tab#...


#tab#flex.cl0ass.path
#tab#...

Merged web.xml

#tab#cf.class.path
#tab#...


#tab#cf.lib.path
#tab#...


#tab#flex.class.path
#tab#...

Although it is not necessary, a node for index.mxml can be added in the node. Be sure to copy the nodes as well.

Now create a web site in IIS. First, create a web root directory. For this example, create it here: C:\Inetpub\wwwroot_cfflex. Open the IIS admin console and begin the process for adding a new web site. Name the site CF/Flex.

Since this site is not used as our default web site (port 80), be sure to change the port from port 80 to port 25000.

Also, be sure to point the home directory path to the directory just created (C:\Inetpub\wwwroot_cfflex).

Only one step remains in the integration of ColdFusion and Flex. Bind the JRun server instance with the IIS website. To do this, run the Web Server Configuration Tool, which is typically located in C:\Jrun4\bin\wsconfig.exe. Click the "Add…" button. Select the server instance under JRun Server Properties and the IIS Web Site under Web Server Properties. In this example, the JRun Server is "CFFlex" and the IIS Web Site is "CF/Flex." Finally, be sure to click the "Configure web server for ColdFusion MX applications" checkbox, and click the "OK" button.

A prompt to re-start the web server will be displayed. Do so to have the new settings take effect. The new CFFlex server can be accessed and serve up .cfm and .mxml files at the following URL:

http://localhost:25000/

If any problems occur, try stopping and starting the server instance in the ColdFusion administrator. It may take a minute for all the new settings to take effect. Troubleshoot other problems by running the "JRun Launcher" and clicking the "View Server Log" button. The JRun Launcher can be found at C:\JRun4\bin\jrun.exe.

Here are the basic steps taken to complete the ColdFusion MX 7 and Flex integration:

 

  1. Create a new ColdFusion server instance in the ColdFusion Administrator.
  2. Run the Flex 1.5 installation program.
  3. Extract the contents of flex.war to a temporary directory.
  4. Copy the \flex directory from the temporary flex directory to the ColdFusion server instance WEB-INF directory.
  5. Copy JAR files from the temporary flex directory to the ColdFusion server instance WEB-INF\lib directory.
  6. Merge the web.xml files.
  7. Create a new web site in the IIS admin console.
  8. Bind the JRun server instance with the IIS website.

 

BlogCFC was created by Raymond Camden. This blog is running version 5.9.002. genuinejd.com