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:
<resource-path>/inet/*</resource-path>
<system-path>C:/inetpub/wwwroot/</system-path>
</virtual-mapping>
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 from Charlie Arehart:Need more help with problems?
- Signup to get his blog posts by email:
- Follow his blog RSS feed
- View the rest of his blog posts
- View his blog posts on the Adobe CF portal
- If you may prefer direct help, rather than digging around here/elsewhere or via comments, he can help via his online consulting services
- See that page for more on how he can help a) over the web, safely and securely, b) usually very quickly, c) teaching you along the way, and d) with satisfaction guaranteed
It's pretty simple in IIS6 (site properties > home directory > configuration).
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.
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!
I added this as suggested:
<virtual-mapping>
<resource-path>/Xee/*</resource-path>
<system-path>C:/inetpub/wwwroot/Xeequa/</system-path>
</virtual-mapping>
And get this when I try to access it
http://127.0.0.1:850...
404
/xee/index.htm
CF8 is on port 8501 because CF7 is on 8500
I run this all on a Vista machine
Any idea?
Thanks a lot
Axel
<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...
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.)