ColdFusion Intermittently Cannot Find CFC, Part II

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:

Start: <cfdump var="#now()#"><br />
<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.

 

Related Blog Entries

Comments

Ben Nadel's Gravatar @Jon,

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 :)
Jon Hartmann's Gravatar @Ben

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?
Ben Nadel's Gravatar @Jon,

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's Gravatar I have actually had a problem like this. And it turned out to be a permission problem for me, I had a cfc that was created on a windows server and then i downloaded it to MAC and I got the same error you're getting and I found that no one have rights to the file, so once a granted access to the account running CF everything worked great. Let me know if that works.
todd sharp's Gravatar Are you using an application specific mapping? If so, don't. I've had random, unexplained errors with CF not finding custom tags related to app specific custom tag paths. Added it to CF Admin and removed the appplication specific mapping fixed it for me for good.
Jon Hartmann's Gravatar @Ben : My trusted cache is turned off and my class file caching is turned on, pretty much as expected. I think I'd need to know more about how the caching works to explore that line more deeply.

@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.
Jon Hartmann's Gravatar @Todd: I think you've got the winning answer. I swapped back to application specific mappings and the problem came back 2 in 5 tries. I then went back to server level mappings and got no errors in 10 or 12 tries. I'm leaving this change in place over night and I'll see if I get any more messages of this kind.

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?
todd sharp's Gravatar I've pinged Adrock to let him know about this. He'll get it to the right people I'm sure.
Sean Corfield's Gravatar I use application-based mappings all the time on Mac and Linux and have never seen this problem.

I notice you have your websites on D: - is your CF install on the same drive? Is D: a local drive
Jon Hartmann's Gravatar @Sean:

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.
Jon Hartmann's Gravatar Ok, so I've got another application setup in the same clustered environment (different instances, different cluster, but same server and circumstances) and I'm seeing a similar error. I've added the mapping to the two instance's CF Admins, lets see if it clears up...
Angela Nimer's Gravatar Did you ever come to any resolution on this? I'm having the same exact issue. I've talked about it with my husband, Mike Nimer (former Adobe CF Engineer) and he said CF is doing some pretty crazy stuff behind the scenes to resolve paths for the CFC's. He said it sounded like a CF server bug. You are using CF 7, correct?

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?
Jon Hartmann's Gravatar @Angela, no, unfortunately I never found out beyond a shadow of a doubt what was going on. All I know is that once I added the mapping to the server through the CF Admin, things started working fine. I'm not sure that your issue is the same as mine though; I'm using CF8, and the issue was occurring when I was relying on a CF8 feature ( this.mappings[] in the application scope). If you're seeing this issue in CF7, than it might point to a completely different cause for the issue other than this.mapping[] being unreliable.
Angela Nimer's Gravatar Thanks Jon, it does sound like a different issue.
Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me.

Post a job. Find one. authenticjobs.com

Interested in becoming a sponsor? Contact me.