Jeff Stevens
04/20/2023, 5:54 PMonSessionEnd()
function:
Error type:
Builder.BuildCFCDependencyException
Error message:
Error building: handlers.Main -> Could not find the included template //includes/helpers/ApplicationHelper.cfm.
Note: If you wish to use an absolute template path (for example, template="/mypath/index.cfm") with include, you must create a mapping for the path using the ColdFusion Administrator. Or, you can use per-application settings to specify mappings specific to this application by specifying a mappings struct to THIS.mappings in Application.cfc. <br> Using relative paths (for example, template="index.cfm" or template="../index.cfm") does not require the creation of any special mappings. It is therefore recommended that you use relative paths with include whenever possible.. | DSL: , Path: handlers.Main,
//includes/helpers/ApplicationHelper.cfm
is not a valid path to my ApplicationHelper.cfm
file, as it adds and extra two forward slashes to the start of the correct path, so I went to my coldbox.cfc
file to see if I could change the path, and found this within the coldbox struct:
applicationHelper : "includes/helpers/ApplicationHelper.cfm"
So it looks like something is appending two forward slashes to the path somewhere, but I'm not sure where.
It is also relevant to mention that this error does not throw in our development environment. It just started with our production environment.
Does anyone have advice for troubleshooting this? Thanks for all the help y'all have given me so far!cfvonner
04/20/2023, 6:19 PMonSessionEnd()
? Maybe show the onSessionEnd()
code. And a stack trace, if available.Jeff Stevens
04/20/2023, 6:29 PMonSessionEnd()
function is called.
Here's the onSessionEnd()
from application.cfc
:
public void function onSessionEnd( struct sessionScope, struct appScope ) {
try
{
arguments.appScope.cbBootStrap.onSessionEnd( argumentCollection = arguments);
}
catch(any e)
{
var appPath = getDirectoryFromPath( getCurrentTemplatePath() );
fileAppend( "#appPath#/logs/application-cfc-errors.log", "Error @#getHTTPTimeString(now())#: " & e.type & " | " & e.message & " | " & e.detail & "|" & serializeJSON(e.tagContext));
//Write the error to the console
writeDump(
var = "Error @#getHTTPTimeString(now())#: " & e.type & " | " & e.message & " | " & e.detail & "|" & serializeJSON(e.tagContext),
output = "console"
);
}
}
Here is the trace:
webroot\coldbox\system\FrameworkSupertype.cfc:722
webroot\coldbox\system\FrameworkSupertype.cfc:744
webroot\coldbox\system\EventHandler.cfc:63|[{"RAW_TRACE":"\tat cfBuilder2ecfc1352572539$funcBUILDCFC.runFunction(webroot\\coldbox\\system\\ioc\\Builder.cfc:242)","LINE":242,"COLUMN":0,"TEMPLATE":"webroot\\coldbox\\system\\ioc\\Builder.cfc","ID":"CFTHROW","TYPE":"CFML"},{"RAW_TRACE":"\tat cfInjector2ecfc113679728$funcBUILDINSTANCE.runFunction(webroot\\coldbox\\system\\ioc\\Injector.cfc:537)","LINE":537,"COLUMN":0,"TEMPLATE":"webroot\\coldbox\\system\\ioc\\Injector.cfc","ID":"CF_TEMPLATEPROXY","TYPE":"CFML"},{"RAW_TRACE":"\tat cfNoScope2ecfc1322277262$funcGETFROMSCOPE.runFunction(webroot\\coldbox\\system\\ioc\\scopes\\NoScope.cfc:43)","LINE":43,"COLUMN":0,"TEMPLATE":"webroot\\coldbox\\system\\ioc\\scopes\\NoScope.cfc","ID":"CF_TEMPLATEPROXY","TYPE":"CFML"},{"RAW_TRACE":"\tat cfInjector2ecfc113679728$funcGETINSTANCE.runFunction(webroot\\coldbox\\system\\ioc\\Injector.cfc:508)","LINE":508,"COLUMN":0,"TEMPLATE":"webroot\\coldbox\\system\\ioc\\Injector.cfc","ID":"CF_TEMPLATEPROXY","TYPE":"CFML"},{"RAW_TRACE":"\tat cfHandlerService2ecfc2003911211$funcNEWHANDLER.runFunction(webroot\\coldbox\\system\\web\\services\\HandlerService.cfc:107)","LINE":107,"COLUMN":0,"TEMPLATE":"webroot\\coldbox\\system\\web\\services\\HandlerService.cfc","ID":"CF_TEMPLATEPROXY","TYPE":"CFML"},{"RAW_TRACE":"\tat cfHandlerService2ecfc2003911211$funcGETHANDLER.runFunction(webroot\\coldbox\\system\\web\\services\\HandlerService.cfc:144)","LINE":144,"COLUMN":0,"TEMPLATE":"webroot\\coldbox\\system\\web\\services\\HandlerService.cfc","ID":"CF_UDFMETHOD","TYPE":"CFML"},{"RAW_TRACE":"\tat cfController2ecfc453873441$func_RUNEVENT.runFunction(webroot\\coldbox\\system\\web\\Controller.cfc:762)","LINE":762,"COLUMN":0,"TEMPLATE":"webroot\\coldbox\\system\\web\\Controller.cfc","ID":"CF_TEMPLATEPROXY","TYPE":"CFML"},{"RAW_TRACE":"\tat cfController2ecfc453873441$funcRUNEVENT.runFunction(webroot\\coldbox\\system\\web\\Controller.cfc:658)","LINE":658,"COLUMN":0,"TEMPLATE":"webroot\\coldbox\\system\\web\\Controller.cfc","ID":"CF_UDFMETHOD","TYPE":"CFML"},{"RAW_TRACE":"\tat cfBootstrap2ecfc1223334166$funcONSESSIONEND.runFunction(webroot\\coldbox\\system\\Bootstrap.cfc:603)","LINE":603,"COLUMN":0,"TEMPLATE":"webroot\\coldbox\\system\\Bootstrap.cfc","ID":"CF_TEMPLATEPROXY","TYPE":"CFML"},{"RAW_TRACE":"\tat cfApplication2ecfc1789641650$funcONSESSIONEND.runFunction(webroot\\Application.cfc:74)","LINE":74,"COLUMN":0,"TEMPLATE":"webroot\\Application.cfc","ID":"CF_TEMPLATEPROXY","TYPE":"CFML"}]
thisOldDave
04/21/2023, 9:04 AMJeff Stevens
04/21/2023, 2:20 PMbdw429s
04/21/2023, 2:20 PMbdw429s
04/21/2023, 2:20 PMbdw429s
04/21/2023, 2:21 PMbdw429s
04/21/2023, 2:21 PM/foo
is a valid path, you don't need ./foo
Jeff Stevens
04/21/2023, 2:22 PMJeff Stevens
04/21/2023, 3:14 PM./
at the front of the path did not do the trick. Here's the new error message:
Error @Fri, 21 Apr 2023 14:24:01 GMT: Builder.BuildCFCDependencyException | Error building: handlers.Main -> Could not find the included template //./includes/helpers/ApplicationHelper.cfm.
Note: If you wish to use an absolute template path (for example, template="/mypath/index.cfm") with include, you must create a mapping for the path using the ColdFusion Administrator. Or, you can use per-application settings to specify mappings specific to this application by specifying a mappings struct to THIS.mappings in Application.cfc. <br> Using relative paths (for example, template="index.cfm" or template="../index.cfm") does not require the creation of any special mappings. It is therefore recommended that you use relative paths with include whenever possible.. | DSL: , Path: handlers.Main,
bdw429s
04/21/2023, 3:25 PMJeff Stevens
04/21/2023, 5:21 PMError @Fri, 21 Apr 2023 16:58:01 GMT: Builder.BuildCFCDependencyException | Error building: handlers.Main -> Could not find the included template ///includes/helpers/ApplicationHelper.cfm.
Note: If you wish to use an absolute template path (for example, template="/mypath/index.cfm") with include, you must create a mapping for the path using the ColdFusion Administrator. Or, you can use per-application settings to specify mappings specific to this application by specifying a mappings struct to THIS.mappings in Application.cfc. <br> Using relative paths (for example, template="index.cfm" or template="../index.cfm") does not require the creation of any special mappings. It is therefore recommended that you use relative paths with include whenever possible.. | DSL: , Path: handlers.Main,
Jeff Stevens
04/21/2023, 7:48 PMapplicationHelper
key in the coldbox.cfc
coldbox struct equal to an empty string, as we aren't actually using anything defined in this file in the app. This made the error stop popping up. However, now we're seeing an error that says our two leading slashes are being prepended to references to our modules. This surely is odd.Jeff Stevens
04/21/2023, 7:49 PMError @Fri, 21 Apr 2023 19:17:32 GMT: Builder.BuildCFCDependencyException | Error building: handlers.Main -> Could not find the included template ///modules/BCrypt/helpers/mixins.cfm.
Note: If you wish to use an absolute template path (for example, template="/mypath/index.cfm") with include, you must create a mapping for the path using the ColdFusion Administrator. Or, you can use per-application settings to specify mappings specific to this application by specifying a mappings struct to THIS.mappings in Application.cfc. <br> Using relative paths (for example, template="index.cfm" or template="../index.cfm") does not require the creation of any special mappings. It is therefore recommended that you use relative paths with include whenever possible.. | DSL: , Path: handlers.Main,
bdw429s
04/21/2023, 7:55 PMbdw429s
04/21/2023, 7:55 PMbdw429s
04/21/2023, 7:55 PMbdw429s
04/21/2023, 7:55 PMbdw429s
04/21/2023, 7:58 PMbdw429s
04/21/2023, 7:58 PMvar UDFRelativePath = expandPath( "/" & appMapping & "/" & udflibrary );
Jeff Stevens
04/21/2023, 8:01 PMbdw429s
04/21/2023, 8:02 PMbdw429s
04/21/2023, 8:03 PM/
mapping points to can be wrong when you move to a sub folder, especally if you're prod server is not working the same as your dev server.bdw429s
04/21/2023, 8:03 PMbdw429s
04/21/2023, 8:07 PMfileExists()
must have returned true for ONE of those checksJeff Stevens
04/21/2023, 8:10 PMJeff Stevens
04/21/2023, 8:12 PMAppMapping
variable that gets concatenated there. I need to figure out how to set that now.bdw429s
04/21/2023, 8:13 PMJeff Stevens
04/21/2023, 8:15 PM// COLDBOX STATIC PROPERTY, DO NOT CHANGE UNLESS THIS IS NOT THE ROOT OF YOUR COLDBOX APP
COLDBOX_APP_ROOT_PATH = getDirectoryFromPath( getCurrentTemplatePath() );
// The web server mapping to this application. Used for remote purposes or static purposes
COLDBOX_APP_MAPPING = "";
// COLDBOX PROPERTIES
COLDBOX_CONFIG_FILE = "";
// COLDBOX APPLICATION KEY OVERRIDE
COLDBOX_APP_KEY = "";
// application start
public boolean function onApplicationStart() {
try
{
application.cbBootstrap = new coldbox.system.Bootstrap(
COLDBOX_CONFIG_FILE,
COLDBOX_APP_ROOT_PATH,
COLDBOX_APP_KEY,
COLDBOX_APP_MAPPING
);
application.cbBootstrap.loadColdbox();
return true;
}
catch(any e)
{
writeDump(e);
// fileAppend( "#appPath#/error.log", "Error: #e.type & "---" & e.message & "---" & e.detail#" );
}
}
bdw429s
04/21/2023, 8:17 PMCOLDBOX_APP_MAPPING = "";
your app mapping is not being set to anything special.Jeff Stevens
04/24/2023, 1:12 PMincludeUDF()
function as you suggested. I edited the FrameworkSupertype.cfc to do some debugging. For includeUDF()
, I added fileAppend()
calls which tell me what fileExist()
condition was met in the inner closure function and ultimately what the returned targetLocation
variable was:
any function includeUDF( required udflibrary ) cbMethod{
// Init the mixin location and caches reference
var defaultCache = getCache( "default" );
var mixinLocationKey = hash( variables.controller.getAppHash() & arguments.udfLibrary );
var targetLocation = defaultCache.getOrSet(
// Key
"includeUDFLocation-#mixinLocationKey#",
// Producer
function(){
var appMapping = variables.controller.getSetting( "AppMapping" );
var UDFFullPath = expandPath( udflibrary );
var UDFRelativePath = expandPath( "/" & appMapping & "/" & udflibrary );
// Relative Checks First
if ( fileExists( UDFRelativePath ) ) {
targetLocation = "/" & appMapping & "/" & udflibrary;
fileAppend("my\absolute\path\webroot\logs\application-cfc-errors.log", "1");
}
// checks if no .cfc or .cfm where sent
else if ( fileExists( UDFRelativePath & ".cfc" ) ) {
targetLocation = "/" & appMapping & "/" & udflibrary & ".cfc";
fileAppend("my\absolute\path\webroot\logs\application-cfc-errors.log", "2");
} else if ( fileExists( UDFRelativePath & ".cfm" ) ) {
targetLocation = "/" & appMapping & "/" & udflibrary & ".cfm";
fileAppend("my\absolute\path\webroot\logs\application-cfc-errors.log", "3");
} else if ( fileExists( UDFFullPath ) ) {
targetLocation = "#udflibrary#";
fileAppend("my\absolute\path\webroot\logs\application-cfc-errors.log", "4");
} else if ( fileExists( UDFFullPath & ".cfc" ) ) {
targetLocation = "#udflibrary#.cfc";
fileAppend("my\absolute\path\webroot\logs\application-cfc-errors.log", "5");
} else if ( fileExists( UDFFullPath & ".cfm" ) ) {
targetLocation = "#udflibrary#.cfm";
fileAppend("my\absolute\path\webroot\logs\application-cfc-errors.log", "6");
} else {
throw(
message = "Error loading UDF library: #udflibrary#",
detail = "The UDF library was not found. Please make sure you verify the file location.",
type = "UDFLibraryNotFoundException"
);
}
fileAppend("my\absolute\path\webroot\logs\application-cfc-errors.log", "The following was the targetLocation intended to include: " & targetLocation);
return targetLocation;
},
// Timeout: 1 week
10080
);
// Include the UDF
include targetLocation;
return this;
}
On starting the server, these messages were logged to the file:
1
The following was the targetLocation intended to include: ///modules/BCrypt/helpers/mixins.cfm
1
The following was the targetLocation intended to include: ///modules/cbauth/helpers/Mixins.cfm
1
The following was the targetLocation intended to include: ///modules/cbmailservices/helpers/mixins.cfm
1
The following was the targetLocation intended to include: ///modules/cbmessagebox/helpers/mixins.cfm
1
The following was the targetLocation intended to include: ///modules/cbsecurity/helpers/mixins.cfm
1
The following was the targetLocation intended to include: ///modules/cbsecurity/modules/cbcsrf/helpers/Mixins.cfm
1
The following was the targetLocation intended to include: ///modules/cbvalidation/modules/cbi18n/helpers/Mixins.cfm
1
The following was the targetLocation intended to include: ///modules/cbvalidation/helpers/Mixins.cfm
No errors here. Things look normal.
Now, when the session ends, we get the following logged message that we've been getting for a while. Interestingly though, none of the fileAppend()
calls appear to have been hit:
Error @Mon, 24 Apr 2023 13:02:26 GMT: Builder.BuildCFCDependencyException | Error building: handlers.Main -> Could not find the included template ///modules/BCrypt/helpers/mixins.cfm.
Note: If you wish to use an absolute template path (for example, template="/mypath/index.cfm") with include, you must create a mapping for the path using the ColdFusion Administrator. Or, you can use per-application settings to specify mappings specific to this application by specifying a mappings struct to THIS.mappings in Application.cfc. <br> Using relative paths (for example, template="index.cfm" or template="../index.cfm") does not require the creation of any special mappings. It is therefore recommended that you use relative paths with include whenever possible.. | DSL: , Path: handlers.Main,
I find this strange because we have clearly defined these function calls before the line where the error is thrown. Do you have any insight on what could be occurring here? I know you mentioned the application mapping being messed up earlier.bdw429s
04/24/2023, 2:28 PMInterestingly though, none of thePresumably because the lookups are cached. If you wanted them to happen every time, you'd need to refactor out the caching.calls appear to have been hit:fileAppend()
I find this strange because we have clearly defined these function calls before the line where the error is thrown.No, you put your logging inside of the cache provider UDF, and the error is actually coming form the cfinclude down below. So the cached value was simply retrieved and then attempted to be cfincluded.
bdw429s
04/24/2023, 2:29 PMbdw429s
04/24/2023, 2:29 PMbdw429s
04/24/2023, 2:30 PMbdw429s
04/24/2023, 2:31 PMbdw429s
04/24/2023, 2:31 PMbdw429s
04/24/2023, 2:32 PMexpandPath( '///modules/cbvalidation/helpers/Mixins.cfm' )
returns at the point that it's erroring. Does it return a valid file path that exists? Does the behavior change if you remove the extra slashes?Jeff Stevens
04/24/2023, 2:53 PMPresumably because the lookups are cached. If you wanted them to happen every time, you'd need to refactor out the caching.Thanks. I don't know much about the caching here, so I probably want to change how I'm logging debug messages here. I don't know what I don't know š
I had totally missed that this is on an onSessionEnd method-- I assume the issue is that whatever mappings Lucee has are missing or different from inside of the onsession endYes, this error is triggered from the onSessionEnd method that lives in
Application.cfc
. That sounds very likely, considering that when the app starts, all of the dependencies are injected correctly. Also it should be noted that we are using Adobe Coldfusion 2021.
I guess, you need to back up a bit and figure out which of these two scenarios is happening.
⢠is the logic to find the file path wrong and returning the wrong path
⢠or is the path totally fine and the cfinclude is simply not finding the file for some reasonThis sounds like the way to go.
I'd be curious in seeing what
Copy codeexpandPath( '///modules/cbvalidation/helpers/Mixins.cfm' )
returns at the point that it's erroring. Does it return a valid file path that exists? Does the behavior change if you remove the extra slashes?I will go and test this out right now. I appreciate your time Brad. We've credited you and some of the other Ortus guys in the new app we've made š
Jeff Stevens
04/24/2023, 3:01 PMexpandPath( '///modules/cbvalidation/helpers/Mixins.cfm' )
during the resolving of the OnSessionEnd() method, this is the directory that gets printed:
C:\ColdFusion2021\cfusion\wwwroot\modules\cbvalidation\helpers\Mixins.cfm
This path is incorrect. Now, we need to know how to change this, or why this is even the case in the first place.bdw429s
04/24/2023, 3:06 PMbdw429s
04/24/2023, 3:07 PMbdw429s
04/24/2023, 3:07 PMbdw429s
04/24/2023, 3:09 PMexpandpath( '/' )
Jeff Stevens
04/24/2023, 3:20 PMDoes removing the extra slashes change anythingIt looks like removing the extra slashes produces a path with the correct absolute path to
modules/cbvalidation/helpers/Mixins.cfm
right before the error is thrown!Jeff Stevens
04/24/2023, 3:22 PMexpandpath( '/' )
during the resolution of onSessionEnd shows: C:\ColdFusion2021\cfusion\wwwroot\
, which is an incorrect path.Jeff Stevens
04/24/2023, 3:23 PMbdw429s
04/24/2023, 3:27 PMbdw429s
04/24/2023, 3:27 PMexpandPath( '/' )
returns
C:/one/path/
but
expandPath( '/foo' )
returns
C:/another/path/foo
?bdw429s
04/24/2023, 3:29 PM/modules
somewhere, the root /
mapping should be the same in all expansionsJeff Stevens
04/24/2023, 5:07 PMexpandPath( '/' ) == C:\ColdFusion2021\cfusion\wwwroot\
expandPath( '/modules/cbvalidation/helpers/Mixins.cfm' ) == C:\ColdFusion2021\cfusion\wwwroot\modules\cbvalidation\helpers\Mixins.cfm
expandPath( 'modules/cbvalidation/helpers/Mixins.cfm' ) == the\correct\absolute\path\webroot\modules\cbvalidation\helpers\Mixins.cfm
Jeff Stevens
04/24/2023, 5:08 PMJeff Stevens
04/24/2023, 5:17 PMbdw429s
04/24/2023, 5:34 PMbdw429s
04/24/2023, 5:35 PMbdw429s
04/24/2023, 5:35 PMbdw429s
04/24/2023, 5:35 PMJeff Stevens
04/24/2023, 5:47 PMJeff Stevens
04/24/2023, 5:48 PMJeff Stevens
04/24/2023, 6:55 PMbdw429s
04/24/2023, 7:22 PMJeff Stevens
04/24/2023, 7:22 PM