Nate, you ABSOLUTELY can override the jvm arg at the app level. I've confirmed it. But I have a guess at why your attempt to override it in your application.cfc is not working. At least this could happen to others.
Are you putting the this.searchimplicscopes=false inside your onapplicationstart, or perhaps onrequest or onrequeststart? If so, that's the problem. Instead, put the setting OUTSIDE those methods, which as some may know has been referred to traditionally in CFML as the "pseudo-constructor" of a CFC.
You can prove this yourself by dumping the getApplicationMetadata() function, which shows what is or is NOT set for such settings as can be set at the application level (and so yes, this issue applies to ANY such application settings).
You can even see this indicated in the docs talking about using application.cfc, though they don't make a point of stressing it. They just show DOING it. As for the docs on the various application settings you can set, those do at least say at the top, "You set the values of these variables in the CFC initialization code, before you define the CFC methods."
Sadly, neither of those doc pages propose the idea of using getApplicationMetadata(), which is the best way to confirm where things stand regarding such settings. And I'll note that if instead one were to dump the THIS scope, you WILL see the change you'd made via the "this." scope even within those methods. But the problem is that that is NOT going to matter, if you don't see it reflected in the dump of getApplicationMetadata().
FWIW, you would not be the first to experience that "changing settings in application.cfc is not working". Of course, those who use application.cfm don't experience this, as they just set the settings on cfapplication instead, which is a more straightforward runtime directive.
Here also is some code you can use to "play with" things:
component {
// this code demonstrates how to correctly and incorrectly) set application-level settings like searchimplicitscopes in application.cfc
// it presumes that the default setting in CF is set to true, and that one wants to set it false for this given app (as discussed in this forum thread)
// to test some changes, you'll want to re-initalize the app.
// while you could call applicationstop(), you could also just change the value of this.name to create a "new" app
this.name="test";
// this line sets the setting correctly, as it's outside any method
this.searchimplicitscopes=false;
writedump(var=this,label="this, in pseudo-constructor")
writedump(var=getApplicationMetadata(),label="getappmetadata, in pseudo-constructor");
function onapplicationstart() {
// this line will NOT set the setting to true, because it's inside onapplicationstart
this.searchimplicitscopes=true;
writedump(var=getApplicationMetadata(),label="getappmetadata, in onapplicationstart");
writedump(var=this,label="this, in onapplicationstart");
}
function onrequeststart() {
// this line will also NOT change the setting. Note you can even set it to an incorrect value without any error,
// which would fail if done on the correct line above (with 'cannot convert the value "xx" to a boolean')
this.searchimplicitscopes="xyz";
writedump(var=getApplicationMetadata(),label="getappmetadata, in onrequeststart");
writedump(var=this,label="this, in onrequeststart");
}
}
You can also add a dump of the scope in a cfm page (such as even a a new test.cfm you may create) in the folder controlled by this application.cfc:
<cfdump var="#getapplicationmetadata()#" label="getappmetadata, in #cgi.script_name#">
Finally, if you may want some code to detect and show if the new JVM arg for searchimplicistscopes is set, this will do it:
// code to detect and show if JVM arg for coldfusion.searchimplicitscopes is set
writeoutput("jvm arg -Dcoldfusion.searchimplicitscopes ");
if (structkeyexists(server.system.properties,"coldfusion.searchimplicitscopes")) {
writeoutput("set to " & server.system.properties["coldfusion.searchimplicitscopes"] & "<br>");
} else {
writeoutput("is not set <br>");
}
I've been meaning to do a blog post on this matter (of how one might mistakenly set the setting), and in answering you here it has helped me gather the thoughts. I'l look forward to hearing what you or others may say, in case there's anything I'm missing.
... View more