Cold Fusion 9 Application Mappings Access Denied
Cold Fusion 9 Mappings
I have been trying to tackle this problem for some time now and have had little to no success with mapping directories directly in the Application.cfc. Trying to extend the Application.cfc seems to be an answer at this time, but not sure just yet. A particular post brought about the ideal of using the cfimport or cfmodule tag which could be a possibility I had not thought of yet.
I have this funny notion that the problem is due to being on a clustered server environment. Mapping from the Application.cfc file does not seem to be an option and it must be done through the CF Admin or by extending the Application.cfc by a component that extends the Application.cfc. At the time of this testing and post I had come to a conclusion that using mappings from the Application.cfc file were impossible, but yet it appeared several other blogs showed the concept to work, but only if the cfinclude tag was in the Application.cfc file itself. One more thing to mention before reading on; is that a IIS server – the forward and backward slashes do not matter. You can use the replace function if it makes you feel better, but is not necessary.
Example: Application Settings
<cfset this.rootdir = getDirectoryFromPath(getCurrentTemplatePath()) />
<cfset this.mappings[ ‘/myinclude’ ] = this.rootdir & ‘ include/ ‘ />
Page you Want to Include the Mapping on:
<cfinclude template=”#this.mappings[ ‘/myinclude’ ]#yourfile.cfm” />
Have covered this topic well and this is what I keep coming to that should work best. The output of the path prints an error message, which shows the path being exactly correct; the error is as follows: “template can not be found“. After all exhausted trials and coding I have found it not to work. Set a global path for the site as well. The problem I am encountering is spanning from the fact the it is run on a clustered environment. The nodes seem to have difficulty on a CF9 server clustered environment. The clustered servers have difficulty trying to convert relative paths between the nodes which are redirects to different servers on this clustered type of environment.
An error occurred after these changes were applied correctly. The error encountered was a Thread Group (access denied error). This Thread Group Settings can be changed inside of the CF Admin, but then it open’s up a security vulnerability on the server. After changes this setting inside the CF Admin, the site worked perfectly with the global mappings running from the Application.cfc. But because of the security issue it had to be changed back. Although this is not on a single instance server hosting Cold Fusion, the problem could have been solved possibly by being on a single instance server, but no way of knowing this just yet unless I upgrade the site to CF10 on a single instance server. At this point it seems Cold Fusion and clustered server environments do not bode well. This is being hosted on an 2008 IIS server.
I think where it is going wrong is the fact that I am using a .dwt template to create the pages. This template has a ../ syntax set for a relative path from the templates directory. This means when a new page is created from the template it uses this ../ syntax on the template. When the new web page being created is only one directory deep, it will work fine. But once you create another page that is more than one directory deep in the hierarchy of the directories the ../ syntax is no longer valid since it is more than one directory deep. This is the problem with the this.mappings scenario. I had a global path set , but even this does not work appropriately.
To test this further I created another directory within a test directory and the same problem occurred as well. It appears the Application.cfc file ExpandPath( ‘.’ ) or getDirectoryFromPath() do not work because it is a absolute path and not a relative path for the cfinclude tag. I know it seems like it should work, but since it is an absolute path vs. a relative it will not work properly. These scenarios and different means of programming havebeen tested thoroughly, appropriate research was done and all possibilities to remedy the situation have been attempted.
The problem still seems to rest within the relative path for the cfinclude tag. A this.mappings option just can not understand when a file is one directory, two directory, or three directories deep. I created a new DB table and inserted the dot syntax in it based on page_id = id in the new table and then queried the information from the DB. Works this way, but is not the correct way. Any suggestions are appreciated.
“Remember it is all in the way you do it.”