CF7, CF8, Jrun and the JVM

As I mentioned in this post, I described, briefly how my development environment is set up, and how I installed ColdFusion 8 onto the same JRun server where I have ColdFusion 7 installed.  A reader inquired about the JVM and if there are any conflicts.  Well, the answer is no, there are not.  Why?  Well, becasue when you deploy ColdFusion 8 as a .ear file onto a server running ColdFusion 7, JRun will use the JRE specifeid in the java.home variable in {jRun root}/bin/jvm.config, which in my case was 1.4.2_09.

Now, I have been running this configuration since the public beta and have not run into any issues with performance, or even errors occurring when running ColdFusion 8 code.  However, I wanted to set-up my ColdFusion 8 to use the same JRE it would if I had done a different install (stand alone, or multi-server).  This was easy enough as you can create custom jvm.config files and use them to run your JRun 'servers'.

Here's to do it.
Disclaimer: This is for Windows only.  I assume the procedure would be similar in a different environment.

  1. Download the latest Java SDK and install it. (You may be able to use the JRE alone, but I didn't test this)
  2. Make a copy of jvm.config (located in {JRun root}/bin } and name it jvm_cf8.config. (You can name it whatever you would like, but the rest of the instructions assume you use this name)
  3. Change the java.home variable from "C:/JRun4/jre" (It may be different for you) to {new SDK Install path}/jre and save the file.
  4. If its running, stop the ColdFusion 8 service.
  5. Open a command window and "cd" to {JRun Root}/bin
  6. Test the new config by typing jrun -config jvm_cf8.config -start {the name of your ColdFusion 8 server in Jrun}.  If you don't get any errors, you can now set up your Windows service to use this config file.
  7. Pressing crtl+c should shut down the JRun server you just started.
  8. Type the following to remove the windows service jrunsvc -remove {the name of your ColdFusion 8 server in JRun}
  9. Now you need to reinstall the Windows service and tell it to use the new config jrunsvc -install {the name of your ColdFusion 8 server in JRun} -config jvm_cf8.config.
  10. You should now be able to start ColdFusion 8 from the Services MMC in Windows.


To verify you are using the updated JVM, log into the ColdFusion Administrator for ColdFusion 8 and go to 'System Information' (It's the blue icon on the top right side of the page) and check the JRE and JVM values.

Running CF8 & CF 7 on JRun with Apache

On my development machine, I run ColdFusion 7 in 'multi-server' mode.  This comes in handy if you need to create a separate instance of ColdFusion because of needs of a project or client.  I also run Apache as my web server.  While I am not a big fan of the httpd.conf file (mostly out of lack of familiarity), it makes it a lot easier to run multiple web sites on Windows XP. (Yes, I know there are tools that allow you to do this with IIS, but all the ones I have tried have been buggy and made messing with httpd.conf a pleasant experience). I also add sites to my HOSTS file and give them a 'domain' of 'dev' (boyzoid.dev, for example).  This makes it easier for me to keep track of which environment I am in, and in a lot of cases, save some typing as I usually abbreviate the project (mic.dev, for example).

Like most ColdFusion developers, I wanted to play with ColdFusion 8 when it went into public beta.  I wanted to be able to use ColdFusion 8 and not have to deviate much from my development practices. I wound up installing ColdFusion 8 as a .ear file and deploying it to the same instance of JRun on which ColdFusion 7 is running.  This way I could manage all my ColdFusion instances in one place.  I ran into one small problem though, how do I get a site configured in Apache to use the ColdFusion 8 server rather than the ColdFusion 7 server? For those who may not know, when you are using IIS and multiserver install of ColdFusion, when you add news 'sites' to IIS, you ccan specify what instance of ColdFusion to use for the site.  The answer was surprisingly simple.

First, keep in mind these instructions pick up AFTER ColdFusion 8 has been installed and deployed to your JRun server and the server is running.  It also assumes that Apache has already been configured to work with ColdFusion

1. Go into your JRun Admin and find the 'server' you specified when you deployed ColdFusion 8, and click the link.  In my case, its named 'cf8'.

2. In the resulting screen, click the 'Services' link in the navigation bar.

3. In the next screen, click the 'Start'button next to the 'Proxy Service'.  Take note of the 'proxy port', we will need that in a bit.

4. Create a directory, with whatever name you woud like) under {Jrun}/lib/wsconfig (In my case, I named it 'cf8'...original, I know)

5. Open up httpd.conf and create a <virtualHost> to use, or you can use an existing one.

6. In httpd.conf and look for a block of code that looks like:

# JRun Settings
LoadModule jrun_module "C:/JRun4/lib/wsconfig/1/mod_jrun20.so"
<IfModule mod_jrun20.c>
    JRunConfig Verbose false
    JRunConfig Apialloc false
    JRunConfig Ssl false
    JRunConfig Ignoresuffixmap false
    JRunConfig Serverstore "C:/JRun4/lib/wsconfig/1/jrunserver.store"
    JRunConfig Bootstrap 127.0.0.1:51020
    #JRunConfig Errorurl <optionally redirect to this URL on errors>
    #JRunConfig ProxyRetryInterval 600
    #JRunConfig ConnectTimeout 15
    #JRunConfig RecvTimeout 300
    #JRunConfig SendTimeout 15
    AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf
</IfModule>


This information is what Apache uses to pass off requests to ColdFusion.

7.  Copy the following lines:

JRunConfig Apialloc false
JRunConfig Serverstore "C:/JRun4/lib/wsconfig/1/jrunserver.store"
JRunConfig Bootstrap 127.0.0.1:51020


8. Paste the above lines inside the <virtualHost> block you created, or chose, in step 6.

9. In the line: JRunConfig Serverstore "C:/JRun4/lib/wsconfig/1/jrunserver.store", change the path so it matches the path of the directory you created in step 4.  Make sure you keep the '/jrunserver.store' on the end.  Don;t worry about the file not being there, it will get added auto-magiaclly.

10. In the line JRunConfig Bootstrap 127.0.0.1:51020, replace the port number (the number after the colon) with the 'proxy port' number we noted in step 3.

11. Restart Apache.

The <virtualHost> you created will now use ColdFusion 8 instead of the default server (which in my case was ColdFusion 7).

How do we know its using ColdFusion 8? Easy, just create a test page with <cfdump var="#server#" />, you'll see a version number that begins with '8'.

You can also use this method for pointing Apache to different instances of the same version of ColdFusion, since, as far as JRun cares, they are all just servers.

BlogCFC was created by Raymond Camden. This blog is running version 5.9. original design by tri-star web design