Tuesday, December 10, 2002

OK, one more time correcting the precompile.bat. Finally right?

Folks, I've got some bad/good news. The news I shared here on 12/5 was wrong. Just flat wrong. Here, finally, is the correct code for precompiling code that a) works with the -f directive if you add it and b) works against code in directories outside the default cfusionmx\wwwroot.

What a long strange trip it's been. If you're new to the discussion, just know that the ultimate (ok, "ultimate" for now) script is as follows:


set MX_INSTALL=c:\CFusionMX
set PATH=%MX_INSTALL%\runtime\bin;%MX_INSTALL%\runtime\jre\bin;%PATH%
java -classpath %MX_INSTALL%\lib\cfusion.jar coldfusion.tools.Compiler
   -webroot %1 -webinf %MX_INSTALL%\wwwroot\WEB-INF %1


which again, should be only 3 lines, with the first modified to be the location of your CFMX install.

You execute it by specifying:

precompile pathname

where pathname is the full path to your CF templates (or a specific filename). If it's just a directory, it compiles all templates in that directory and below.

See previous blog entries for more details:

12/5
11/28
6/27

The big point is that I was grossly mistaken in my offered solution of 12/5 (here) where I suggested the problem (with the -f directive failing after updater 1) was related to an issue of jvm versions, and to change the script to look in cfusionmx\runtime\bin, etc. Just forget all that. Mea culpa, mea culpa. Maxima mea culpa. (Latin for I really screwed up and am very sorry)

Someone pointed out that there was no Java.exe in the runtime\bin. I'm so disappointed that I posted incorrect information. What worked for me didn't for others for reasons I won't bother you with. But his pointing it out got me to investigating and I've figured things out. Very interesting discoveries. The bottom line is that if you'll change the bat file to what I offer above, it will work.

It turns out I was mistaken about several things and it was confusion from someone suggesting shortening the 3 lines to 2 by dropping the path line and prefacing the Java command with the path to the jvm. That was the original mistake. We had changed it to runtime\jre\bin because that was the location of the Java command in CFMX.

But while that worked ok if one left off the -f directive to the cfusion.jar compiler, it failed when one added it. And I can now see that the error of our ways was that removal of line 2. It's purpose wasn't to point to the location of the Java command. It was pointing at the jikesw.exe which is called during the compiler (with the -f switch), and it's THAT (jikesw.exe) that's in the cfusionmx\runtime\bin and for which the path is needed.

I won't belabor you the details of how I got so confused--or how much I spun my wheels once I was informed of the bad code fragment I gave before finally realizing the source of my mistake.

Anyway, to conclude, there is no Java.exe in the cfusionmx/runtime/bin. This all has nothing to do with the version of the jvm (1.4 or otherwise). That updated batch file should work and all will be right with the world now. :-) And we're all reminded how a single line of code can make or break a program!