Rather than have multiple copies of the same downloaded ColdBox version on a single server, I thought I’d keep them in a central location to be shared among many CB applications. I’m having issues though which seem somehow related to caching (Save Class Files and Component Cache) on ColdFusion Server 9.0.1 running on IIS. When creating additional CB applications I receive a variety of strange errors, usually starting with this one: Error in instantiating the cfc model.ORMEventHandler but I get others as well at other times and I can’t seem to nail down exactly what is wrong.
If I remove all the Saved Class Files and restart the server then usually the first app I try works fine. Then the second and other others exhibit strange behavior. I’m using unique this.name values (see Application.cfc below). If I turn off Save Class Files all together then I don’t seem to have the problem any more. I understand that on dev boxes Save Class Files should be disabled, however, it is enabled on our production server (and will remain so) and I need to know how to set all this up to best avoid headaches as I promote my code to production.
I’ve found a couple helpful discussions but just can’t seem to piece the puzzle together:
-
http://www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/273
My questions are:
- Is there a recommended filesystem structure for this situation? I’m fine with moving them out of the webroot, and honestly at this point I’d also be fine placing a complete copy of Coldbox in each App directory as well if it will solve the problems.
- Is there an advantage to using a CF Admin mapping vs app-specific? I’m just trying to keep life as simple as possible…and if Save Class Files is going to be enabled on the production server what is my best approach here?
Thanks CB community!
My (mostly futile) attempts have been attempting this structure:
- webroot/
- org/
- coldbox/
- coldbox_3.8.0/
- system/
- core/ … etc
- coldbox_3.8.1/
- App1/
- config/
- Coldbox.cfc
- handlers/
- includes/
- layouts/
- model/
- views/
- Application.cfc
-
App2/
-
App3
-
App4
Then using the bootstrap method with application-specific mappings:
Application.cfc
`
component output=“false”{
// Application properties
this.name = “App1” & hash(getCurrentTemplatePath());
this.sessionManagement = true;
this.sessionTimeout = createTimeSpan(0,0,30,0);
this.setClientCookies = true;
this.mappings[’/coldbox’] = expandPath(’/org/coldbox/coldbox_3.8.1’);
this.mappings[’/includes’] = GetDirectoryFromPath( GetBaseTemplatePath() ) & “includes”;
this.mappings[’/images’] = this.mappings[’/includes’] & “\images”;
this.mappings[’/javascript’] = this.mappings[’/includes’] & “\javascript”;
this.mappings[’/styles’] = this.mappings[’/includes’] & “\styles”;
this.mappings[’/templates’] = this.mappings[’/includes’] & “\templates”;
// Mappings Imports
import coldbox.system.*;
// 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 = “”;
// ORM Settings
this.mappings["/model"] = GetDirectoryFromPath( GetBaseTemplatePath() ) & “model”;
this.ormEnabled = true;
this.datasource = “dsApp1”;
this.ormSettings = {
cfclocation = “model”,
dbcreate = “none”,
dialect = “MicrosoftSQLServer”,
schema = “app1”,
logSQL = true,
flushAtRequestEnd = false,
eventHandling = true,
eventHandler = “model.ORMEventHandler”
};
…etc
}
`