WEB-INF\cftags\META-INF\taglib.cftld (The system cannot find the path specified)

Recently I moved a long running process inside a cfthread and began to get this error during testing: “WEB-INF\cftags\META-INF\taglib.cftld (The system cannot find the path specified)”

The issue is that getPageContext().getServletContext().getRealPath(“/WEB-INF”) returns the incorrect path when inside a cfthread.

If you use cfthread you may eventually run into this bug, but maybe not as I think its a very rare bug. There doesn’t seem to be a fix for this issue, at least not in CF9, but I did find a workaround.

A demonstration of the bug






    
    
    

The results:

C:\ColdFusion9\wwwroot\WEB-INF\
C:\wwwroot\WEB-INF

Inside the cfthread Coldfusion has forgotten where /WEB-INF is!

In my case I had:


in the code inside the cfthread.
“New Query()” corresponds with the custom tag C:\ColdFusion9\CustomTags\com\adobe\coldfusion\query.cfc.
Query.cfc extends C:\ColdFusion9\CustomTags\com\adobe\coldfusion\base.cfc.

To create this object Coldfusion calls “getSupportedTagAttributes” in base.cfc which looks up the attributes in taglib.cftld. That file is located under the /WEB-INF directory. If we dig into the guts of base.cfc we find the offending code is on line 228. Coldfusion tries to find “/WEB-INF/cftags/META-INF/taglib.cftld” but since we are inside a cfthread the code fails to use the correct path.

Creating a mapping didn’t help and neither did creating a virtual directory in Apache.

The workaround

Code similar to this was working fine in the production environment, but how was it avoiding this error? The solution was found when I stepped back and read the entire function. Wrapping the offending line is the code:

if(not isdefined("server.coldfusion.serviceTagAttributes.#tagName#"))

Coldfusion will look up the attributes only if they are not already cached in server memory. This is why this bug is hardly seen: normally all these attributes have been cached before being encountered inside a cfthread. My testing was very specific and so the Query attributes were never loaded prior to entering the cfthread. The trick is to make sure the attributes are cached before entering the cfthread.

For testing I added the line:


before entering the cfthread and that forced the attributes to be cached and the error went away.

I hope this post helps someone else with this issue!

4 thoughts on “WEB-INF\cftags\META-INF\taglib.cftld (The system cannot find the path specified)”

  1. This exact problem occurs with new Http() also. You’re solution worked perfect. I had trouble duplicating it at first because the server variables would always exist from other sources, but if you ctrl-alt-delete your Jrun process and then run a page which uses an any base.cfc object in a thread the error will re-appear.

    It is interesting to note that this bug does NOT affect cfquery and cfhttp, only when referenced using the ‘new’ syntax.

    I’m currently experimenting with adding a new http(); new query(); to the top of my onApplicationStart(). I think it would be a more elegant solution since I don’t necessarily know ahead of time what code will be executed in a thread. Hopefully this will allow me to fix it one spot for an entire application.

Leave a Reply

Your email address will not be published. Required fields are marked *