ColdFusion 2016: cfinclude dynamic template name; occasional error - coldfusion

Good day -
My work group upgraded from CF10 to CF2016. We have finished 2 of the 3 servers that run the application behind a load balancer.
Since the two servers have been upgraded, we get an occasional (<<1%) error on <cfinclude> statements:
The process cannot access the file because it is being used by another process
The included files are different each time, but they have the same characteristic: the names are dynamically generated in the cfinclude tag. For example:
<cfinclude template="#fileManager.getFile('appl1')#">
where #fileManager.getFile('appl1')# simply returns a string path to a CFM file. The file definitely exists, and it is not e.g. being modified by a programmer or any other (known) process. The files themselves are generally just simple index.cfm files in directories that haven't been touched in a year.
This only happens on dynamically named templates in <cfinclude>, never static template names.
Here are the cache settings on the server. Please note that the settings are the same on the server that doesn't experience this problem (the CF10 server)
Any ideas what can cause this random, fleeting error? I can not establish any pattern other than CF2016.

Related

Conflicting mapping for two ColdFusion Applications

I've spent over a day now trying to resolve an issue where two applications use the same relative paths but are under a different "root", and this causes the wrong code base to be accessed for one of the applications.
These are my roots to the two Applications:
\www\Clients\
\www\Other\Clients\
Structure
..www
....Clients
......Application.cfc
....Other
......Clients
........Application.cfc
In both Applications there is code that references the relative path (e.g., /clients/content/login.cfm)
I noticed that the ColdFusion Administrator has a Mappings section where the first mapping has a logical path / mapped to the directory path D:/www/.
This works well for the first application since the clients folder is found directly under the www folder, however the second application doesn't work correctly as it too adheres to the same mapping. Therefore instead of searching for /clients/content/login.cfm under the Others folder, it searches yet again under the www folder.
Note: Both applications have a different Application.Name so they are indeed segregated.
The biggest red flag is that we don't experience this issue on our older ColdFusion 9 server, however we are experiencing this on the newer ColdFusion 2016 server.
Sifting through ColdFusion Administrator, I can't seem to find any other settings which could affect the underlying root per Application which could take precedence over the Mappings.
Is there a setting I missed? Was there a drastic change regarding relative paths or mappings between ColdFusion 9 and ColdFusion 2016?
Sifting through ColdFusion Administrator, I can't seem to find any
other settings which could affect the underlying root per Application
which could take precedence over the Mappings.
Solution: Use application specific mappings.
<cfset this.mappings["/Clients"] = GetDirectoryFromPath(GetCurrentTemplatePath())>
Source

Is there a way to stop ColdFusion 11 from caching Fusebox circuit.xml.cfm files?

Is there a way to stop ColdFusion 11 from caching Fusebox circuit.xml.cfm files?
I have to restart the coldfusion service every time I make a change to a fuseaction file and it's getting tiring.
There are 2 settings in play here. One is "trusted cache" - a setting in the CF admin that does not "check" for a modification once a class has been compiled. You can turn trusted cache off and CF will begin to check for modifications.
The second (and more likely) setting is "parsed" setting. This setting actually saves all your include files into a "parsed" directory and compiles the from there. You can try adding the following to your URL:
Fusebox.parseall=true or alternately Fusebox.loadclean=true - one of these might work.
Finally there is a "mode" setting you can modify to "development" from "production" - that will cause the whole thing to be reparsed.
This is from memory - but maybe it will be enough to get you going. good luck! :)

Locating Specific Files on a ColdFusion Server

So I've began working with .cfm files recently at work, currently my assignment is to modify and update webpages to be more suited to mobile devices and tablets. Now, being relatively new to ColdFusion, I've been having a bit of trouble with how multiple .cfm files are used within a server to create a single webpage. Because of this, I've had issues with finding where specific sections of HTML are located, be it something as where a simple tag is, or where a call to another .cfm, javascript, or .css file may be. Is there anyway to find the origin of certain code without having to skim through hundreds of different files?
If you are working on your code on a local webserver on your computer (i.e. not a production site) then you can enable ColdFusion's debugging output.
Documentation for the ColdFusion Administrator debugging options are here: ColdFusion Administrator Debugging
You will want to enable Enable Request Debugging Output and turn on Report Execution Times. When you browse to the page, ColdFusion will give you a list of all files that ColdFusion used to render that page (with how long each file took) appended to the bottom of the page.
Otherwise, any good IDE/Editor (CFBuilder, SublimeText, NotePad++ etc) will be able to search across files.
I would suggest downloading the code from your server to a local drive. From there you can search using an IDE (ColdFusion Builder, Dreamweaver, etc) or a good text editor that can search multiple files at once. I personally use ColdFusion Builder 3 and Notepad++.
Multiple cfm files are put together into a single page usually by using the cfinclude tag, so that would be a good starting point for your search. There are other methods to include different pages into a single page but cfinclude is probably the most common one. BUT, if the programmer used cfscript instead of cfml, look for the include function instead.
Adobe documentation on the cfinclude tag can be found at https://wikidocs.adobe.com/wiki/display/coldfusionen/cfinclude.

coldfusion application.cfc not found

I've been having a sporadic problem for a few weeks where on restarting the CF Server (Enterprise 9) one of my applications runs without ColdFusion referencing all the variables in the Application.cfc file. It's in the same folder as the CFML pages, it IS properly capitalised as Application.cfc, but it seems to just be ignored. Obviously this causes problems with datasource name and all the other variables I set in Application.cfc. For reference, I'm using an Application.cfc file based on Ben Nadel's excellent intro at http://www.bennadel.com/blog/726-ColdFusion-Application-cfc-Tutorial-And-Application-cfc-Reference.htm . Usually my requested template runs as an include and I can see it in the stack using debugging output, now I can't see it there at all. It's as if the file just doesn't exist.
Has anyone else experienced this, or can you think of possible solutions? Note that at times a restart has got the whole thing running perfectly smoothly.
Re folder structure it's really simple: the Application.cfc file is in the web root along with executable CFML templates - included templates, images, CSS etc are in separate folders referenced via relative paths.
There is another application with its own similar Application.cfc file that is in a sub-directory of the web root. This is running perfectly.
Try clearing your template cache. I've see cases where CF just gets flakey and the cached files are causing issues. Another option: Does ColdFusion have permissions to read/execute the Application.cfc? If this WAS an issue but is no longer an issue I've seen cases where the template cache was causing these files not to be found. Again, delete these files (from disk, not the cfadmin) and try again.

Which file extensions are affected by ColdFusion's Trusted Cache

Which file extensions are cached by Trusted Cache? CFM and CFC are obvious ones, but what about CFR? Are there are other file extensions that are caught by Trusted Cache?
Some places I know/suspect that files enter the template cache are:
directly specified in the url (cfm, cfml, cfc, more?)
cfinclude (any file extension that is used in a cfinclude e.g. <cfinclude template="./some.css">)
cfmodule (cfm, more?)
cfimport (cfm, also jar and tld?)
cfobject, createobject (cfc, also .net, com, java, and web services?)
cfreport (cfr which can be complied with cfcompile utility?)
Are there other tags that will have the same effect of adding content into the template cache?
Adobe ColdFusion (and Railo) compile CFML templates to JVM bytecode and, if configured to do so, will write the compiled class(es) to disk as .class files. The template cache is a mechanism for saying: if the target class is already loaded, don't bother looking at the (source) file on disk to see if it needs recompilation - trust what's in memory.
Recent enhancements to ACF and Railo allow you to specify that (source) files can be checked always (not trusted), once per request, never (always trusted).
That shouldn't be news to anyone.
Obviously ACF and Railo will compile any .cfm or .cfc file they are asked to process so those will "end up" in the trusted cache if it is enabled.
If you cfinclude a file - any file - ACF and Railo will also compile that to JVM bytecode (and create a .class file on disk if configured to do so). Since an included file is compiled, it will also "end up" in the trusted cache. What happens if you include a CSS file then? It gets compiled to bytecode that outputs the entire content of the CSS file as a string to the response stream. Since it is a compiled class, that now outputs a hardcoded string, if you change the CSS source file and have trusted cache enabled, ACF and Railo will trust what's in the classloader and not recompile it (assuming "never" check source is the admin setting).
You can verify this by cleaning out the cfclasses folder, restarting your CFML engine and running your code. You'll see a .class file appear for your CSS file (assuming you have save class files to disk enabled).
So, cfinclude forces compilation of "any" file and the normal rules of trusted cache apply for classes loaded into memory.
I no longer use ACF so I can't speak in detail to .cfr files (Railo does not support report files) but it will most likely depend on whether ACF compiles a .cfr file or not. It should be easy to verify (by looking in the cfclasses folder).
By default, ColdFusion ships with the *.cfm, *.cfc, and *.cfml extensions mapped in JRun as the extensions that are trusted. You may view these mappings by opening up the j2ee-web.xml and web.xml config files in \JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\ (or near this, based on your installation):
<servlet-mapping id="coldfusion_mapping_3">
<servlet-name>CfmServlet</servlet-name>
<url-pattern>*.cfm</url-pattern>
</servlet-mapping>
<servlet-mapping id="coldfusion_mapping_4">
<servlet-name>CFCServlet</servlet-name>
<url-pattern>*.cfc</url-pattern>
</servlet-mapping>
<servlet-mapping id="coldfusion_mapping_5">
<servlet-name>CfmServlet</servlet-name>
<url-pattern>*.cfml</url-pattern>
</servlet-mapping>
However, you can also manually configure brand-new mappings here as well, which will allow ColdFusion to parse/compile CFML tags in files with a different extension as well (I've worked with CF Servers that have been configured to parse .shtml, for example)
Note: You'll also have to do some additional configuration for your web server, be it Apache, IIS, or whatever.
Once CF is configured to handle a file of a particular extension, it is added to the list of files that is processed in the Trusted Cache--since that file ultimately equates to a compiled .class file under-the-hood.
Unfortunately there isn't an official source for this information. However, it is possible, with a lot of work, to test each and every tag to see if the files end up in the Trusted Cache.
Your first two bullet points are covered by Shawn Holmes' answer and Sean Corfield's answer, respectively.
Bullet 3: cfmodule is limited to cfm files, so that extension is the only one you have to worry about there.
Bullet 6: cfreport shouldn't enter the template cache, since it's converting the file, not compiling it for code to execute.