ColdFusion Intermittently Cannot Find CFC, Part II
- March 4, 2009 8:36 AM
- ColdFusion, Mystery Error Message
- Comments (14)
Ok, follow up to yesterday's post "ColdFusion Intermittently Cannot Find CFC". I've updated my tests and still no answers. Help me figure out why ColdFusion sometimes doesn't want to CreateObject().
I suggest that if you are new to the discussion, you read the previous posting. That will help more then a rehash can. Basically, like 200 or 300 times out of 10,000 ColdFusion is refusing to find a CFC to instantiate it. Here is my current test:
<cfset count = 0 />
<cfset filenotfound = 0 />
<cfset errors = ArrayNew(1) />
<cfset times = ArrayNew(1) />
<cfloop from="1" to="2000" index="x">
<cftry>
<cflock name="getEngine" timeout="2">
<cfset objGradeEngine = CreateObject("component", "myapp.cfc.util.gradingEngine.district7Engine") />
</cflock>
<cfcatch>
<cfset count = count + 1 />
<cfset ArrayAppend(errors, cfcatch)>
<cfset ArrayAppend(times, now())>
</cfcatch>
</cftry>
<cfif NOT FileExists("d:\websites\ myapp.\cfc\util\gradingEngine\district7Engine.cfc")>
<cfset filenotfound = filenotfound + 1 />
</cfif>
</cfloop>
File not Found: <cfdump var="#filenotfound#"><br />
CreateObject error Count: <cfdump var="#count#"><br />
Iterations:<cfdump var="#x#"><br />
<cfif ArrayLen(errors) gt 0>
<cfdump var="#errors[1]#" >
</cfif>
<cfif ArrayLen(times) gt 0>
First: <cfdump var="#times[1]#" ><br />
Last: <cfdump var="#times[ArrayLen(times)]#" ><br />
</cfif>
End: <cfdump var="#now()#">
And here is the latest result:
This means that ColdFusion can see the file exists, but can't create the object.
Comments
I don't have a great understanding about the way ColdFusion compiles class files; but, is it possible that it's checking the trusted cache for the class definition and cannot find it... but, FileExists() checks the file system, not the cache?
Sorry if I have no idea what I'm talking about :)
Thats an excellent question. I'll see what I can find out about if the trusted cache plays a part in this, but taking a guess, I'm not really sure why that would be; if it has it 1000+ of 2000 tries, why would it not have it the other times?
Im just grasping at straws here :) Maybe its a memory issue? Perhaps the compiled classes are being garbage collected incorrectly to make room for new instances?
@Spiraldev: Well, I've been in Windows the whole time, but it could be a permissions issue.. my question is though that wouldn't the permission knock it out 100% of the time?
@Todd: I was using an application level mapping, you're right. I tried swapping to server level mapping and I've not been able to reproduce the error in around 50 test runs (meaning ~100k tries). I'm now going to swap back and see if the problem returns. Its also possible that since this issue seems to be intermittent, that I might just not be hitting it correctly right now.
This is really bad news though if it turns out to be the cause... if we can't get app specific mappings, how long will it be before we can have app specific data sources and everything else?
I notice you have your websites on D: - is your CF install on the same drive? Is D: a local drive
Yes, the mapping was to the local system. In fact, the mapping was to the root of the application that was being executed. I do this because my applications in development are often at addresses like test.company.com/dev/ and the live version is myapp.company.com Usage of the mapping made it easier to deploy apps without needing to change to use "cfc.whatever" as the CFC inits rather then "dev.cfc.whatever".
Your comment though does make me question one part of the setup... perhaps its not the application level mapping itself, but the way I did it. In my application.cfc I had the following line: <cfset this.mappings["/myapp"] = GetDirectoryFromPath(GetCurrentTemplatePath()) /> which should have always resulted in the root of my application. Is it possible that that was failing somehow?
I think the part of this that gets me is that it was working like 9,700 times out of 10,000, and not all or nothing.
He thought perhaps this was fixed in 8 which I told him does not help when you have to stick with 7 by the client's choice! :-) (I have no proof this is fixed in 8 anyway.)
Have you submitted your test cases and bug to someone at Adobe?