[Looking for Charlie's main web site?]

Testing code in CF8 and earlier releases--in the same code directory

Note: This blog post is from 2007. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.
As folks contemplate moving to CF8 from 6 or 7, they may know that they can run these releases alongside each other--as long as you use a separate web server (or web site in servers that support it) configured to hand CFML requests to each CF server. Since CF6, CF has included a built-in web server to help with this very issue, especially on servers (like IIS on XP) where you can't have more than one site.

But what if you want to test some code in a single directory against one or more editions? Is that possible? I mean, let's say you have CF7 setup against IIS, and your code is in the c:\inetpub\wwwroot? And you've installed CF 8 for testing using its built-in web server, which runs on port 8500 (or whatever you chose) and finds its code in, for instance, c:\coldfusion8\wwwroot.

How would you have CF8 look at the code you've long had running in the IIS root? (or Apache, or a virtual directory you've setup for use by either external web server). Do you have to move the code around among these directories to test it on different versions of CF? No, you don't.

The trick is in the jrun-web.xml, which you can find in cfusionmx_home]\wwwroot\WEB-INF\jrun-web.xml . You can add a new "virtual-mapping" entry there, naming a new "alias" which points to files outside the normal CF-based wwwroot:


So now a request for http://localhost:8500/inet/ will look instead in the inetpub/wwwroot, or wherever you point it.

Update: Note that when you use the resource-path, it's case-sensitive, even on Windows, so http://localhost:8500/INET/ would not be the same.

Of course, this works also if you set up CF8 to run via your built-in web server, but setup CF 7 or 6 to run on its own built-in web server. And of course, if you're savvy enough you may figure out how to run things so that you can run all 3 using an external web server.

There are a couple of potential challenges with this technique. For one thing, if your code has hard-coded references (such as hyperlinks, images, CFLOCATIONS, etc.) to either run on a particular host (without the port) or at a particular root-relative path, then this introduction of a new port or the /inet/ alias may hamper it working. That's not a "CF" problem but rather a coding one. Your stuck then.

But it certainly works well for testing individual files. I do it all the time and have for years. Indeed, I'll share, for the sake of posterity, that this modifying of the jrun-web.xml is something I first wrote about back in 2002, but many may have missed when such info was being shared.

I'm going to go back and reprise a lot of those "oldies but goodies", spread across a few different blogs I've had over the past several years. I think I'll call them "carehart classics".

For more content like this: Need more help with problems?
  • If you may prefer direct help, rather than digging around here/elsewhere or via comments, I can help via my consulting services
  • See that for more on how I can help a) over the web, safely and securely, b) usually very quickly, c) teaching you as we go, and d) with satisfaction guaranteed
Separate web servers? How about separate web sites on the same server?

It's pretty simple in IIS6 (site properties > home directory > configuration).
# Posted By Patrick McElhaney | 8/3/07 1:55 PM
Patrick, that's all I meant by "And of course, if you're savvy enough you may figure out how to run things so that you can run all 3 using an external web server. "

That's one approach, and there are even ways to get it to work in XP, whether using virtual directories (which I wrote about in the CFDJ in Sep 2003, or using tools like IISAdmin or Multisite (which I blogged about a couple years ago at http://bluedragon.bl...). Funny, both those are right about this same time of year.

Anyway, I just didn't want to take this entry down those alternative paths. Still, I should have been more explicit, at least clarifying how those on other than XP, or even just those using Apache, could solve the problem otherwise.

The main point was simply to explain, for those who didn't know, the option to extend the virtual mappings in the built-in web server.
# Posted By Charlie Arehart | 8/3/07 3:21 PM
Oh, okay, I was thrown off by the first sentence: "... run these releases alongside each other--as long as you use a separate web server for each."

For posterity, you might want to rephrase a bit, e.g.: "... run these releases alongside each other by using a separate web server for each."

Makes, sense now. Thanks. Good tip!
# Posted By Patrick McElhaney | 8/3/07 4:10 PM
OK, I've reworded the end of that first paragraph quite a bit. Don't mean to confuse anyone. Thanks for the input, and the comments above will stand as further info for those interested.
# Posted By Charlie Arehart | 8/3/07 4:31 PM
Hi Charlie - this sounds like a good plan but I can't get it to work.

I added this as suggested:

And get this when I try to access it

CF8 is on port 8501 because CF7 is on 8500
I run this all on a Vista machine
Any idea?
Thanks a lot
# Posted By Axel Schultze | 9/2/07 3:57 PM
Axel, I noticed that you defined the resource-path as /Xee/ but used it as, which made me wonder if perhaps the resource-path is case-sensitive. Indeed, it appears that it is (even on Windows). I have updated the entry to clarify that. Test using Xee in URL and let us know how it goes.
# Posted By Charlie Arehart | 9/3/07 11:33 AM
Thanks Charlie - indeed it is case sensitive! Wow, didn't expect that. Thanks a lot it works!!!
# Posted By Axel Schultze | 9/3/07 2:53 PM
Now, I try to cfinclude a file
<cfinclude template="/core1/maintenancecheck.cfm">
It comes back with an error:
>>> Could not find the included template /core1/maintenancecheck.cfm.

I tried to add mapping in CF Admin but didn't help
If I put the missing file in Coldfusion8/wwwroot/Core1 it finds the file but defeats the purpose.

It looks like the mapping works only for relative links...
# Posted By Axel Schultze | 9/3/07 5:09 PM
Axel, it's definitely true that the mapping in the jrun-web.xml is only for browser requests using the built-in web server. It definitely DOES NOT affect CFINCLUDEs. But that's where, indeed, the solution is in the CF Admin mappings.

You say you tried it and it failed, but it certainly should work. If you declared "core1" as a mapping that points to a directory in the inetpub\wwwroot (or whatever IIS directory you're using), that should work as long as the included file is there.

(CF caches for a given request where it finds a custom tag for that request, such that you need to restart for it to find it in a new location. I don't think it does that for CFINCLUDE ever, so I don't think that's your problem, but it's worth a try.)
# Posted By Charlie Arehart | 9/3/07 7:12 PM
Copyright ©2019 Charlie Arehart
Carehart Logo
BlogCFC was created by Raymond Camden. This blog is running version 5.005.
(Want to validate the html in this page?)

Managed Hosting Services provided by
Managed Dedicated Hosting