Hello
I am seeing the below error when coldbox loads.
“The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code. Null Pointers are another name for undefined values.”
This is something that happens mostly on production after a cf update or restarts and didn’t see it happen in a staging environment till today ( I did a restart of CF service yesterday ) to debug. Another restart fixes the issue.
The application loads correctly up to \coldbox\system\web\config\ApplicationLoader.cfc - // call environment method if exists
if( structKeyExists(arguments.oConfig,configStruct.environment) ){
evaluate(“arguments.oConfig.#configStruct.environment#()” );
}
To debug I updated the code like below
if( structKeyExists(arguments.oConfig,configStruct.environment) ){
try {
evaluate(“arguments.oConfig.#configStruct.environment#()” );
}
catch(any e) {
writeDump(“failed!”);
writeDump(e);
writeDump(configStruct.environment);
writeDump(arguments.oConfig.staging());
writeDump(arguments.oConfig);
}
abort;
}
with below results
failed!
struct
Message [empty string]
StackTrace java.lang.NullPointerException
Suppressed
array [empty]
TagContext
array [empty]
Type java.lang.NullPointerException
staging //configStruct.environment
hello //arguments.oConfig.staging()
STAGING
function staging
Arguments: none
ReturnType: Any
Roles:
Access: public
Output:
DisplayName:
Hint: staging environment
Description:
body of staging function in coldbox.cfc
function staging() { // it is an empty function - just used a return string to get an output for dump.
return “hello”;
}
writeDump(arguments.oConfig.staging()); //works
writeDump(arguments.oConfig.STAGING()); //works
writeDump(evaluate(“arguments.oConfig.STAGING()”)); //works
writeDump(evaluate(“arguments.oConfig.staging()”)); //fails
My questions :
- Why is evaluate being picky on case of the function name - but not always? If I do a fwreinit many times after the app loads once - its fine.
- Change the detectenvironment() function to return upper case string? I did do evaluate( “arguments.oConfig.#UCase(configStruct.environment)#()” ); and it worked.
Thanks,
Aswin