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!

The method matches was not found in component:Ensure that the method is defined, and that it is spelled correctly.

I recently updated my local CF build to 9.0.2. After installation I reloaded my app and everything worked fine. I then went back into the admin and enabled robust exceptions and a few other things for my dev environment. I also saw an option to turn off CFC type check. I had never tried this before so I turned it on to see if there was a speed difference. Instead my app stopped loading and displayed this error:

“The method matches was not found in component C:/wwwroot/MyApp/myComponent.cfc .:Ensure that the method is defined, and that it is spelled correctly.”

Digging into the code, the issue is inside Coldspring. “Matches” is a function used by Coldspring in the ProxyFactoryBean.cfc. With CFC type check turned off it seems that Coldfusion can no longer follow the CFC inheritance and does not realize that this function exists. Turning CFC Type check back off in the CF admin solved the issue, though I am still unsure why this was a problem.

The only other info I found on this issue was this Google Groups thread.

cftag2cfscript – The cftag to cfscript converter for Coldfusion

Just uploaded my new project cftag2cfscript to github this morning.

With the arrival of Coldfusion 9 we can finally build our cfcs in cfscript. I’ve found that there can be a significant speed increase when converting an existing tag based cfc to cfscript. YMMV of course. Others may want to convert legacy cfcs to cfscript because they prefer writing in cfscript. Whatever your reason is for wanting to convert cf tags in to script cftag2cfscript is here to help.

Converting tag-based CF to script based CF is time consuming. This project aims to make it dead simple. Its not there yet, but maybe with your help we can reach that goal.

Checkout cftag2cfscript on Github

A difference between cfloop and for loop in cfscript

I am moving key parts of a codebase to cfscript to take advantage of the speed boost that comes with using cfscript. Along the way I’m discovering the differences between tag-based Coldfusion and cfscript.

Today this was the bug I worked out:

This code will delete 10 widgets:




 

This cfscript will only delete 5 widgets:

var i = 1;
setNumberofWidgets(10);
for(i=1;i<=getWidgetTotal();i++)
{
deleteAWidget();
}

This is because getWidgetTotal() will be called on each iteration of the loop. After deleting 5 widgets the loop will exit because there will only be 5 widgets left and i will equal 5. The cfloop tag from the first example will only evaluate once before starting the loop.

This cfscript will delete 10 widgets:

var i = 1;
var total = getWidgetTotal();
setNumberofWidgets(10);
for(i=1;i<=total;i++)
{
deleteAWidget();
}

By calling the function before starting the loop we can get the total number of widgets and are then able to complete the loop.

CFBuilder, we need to talk

Dear CFBuilder,

I tried, I really tried. You came with a great reputation, and everyone stuck up for you. And though we’ve fought every single day for two years now I can honestly say that I’ve tried to make this relationship work.

I loved your code introspection. The ability to click on a method call and jump right to where that method is defined was a great help. And your ability to intelligently refactor code was also wonderful. There were little things too, like your built-in server controls. And of course I’ll never forget that your code hinting was completely up to date with CF9.

But living with you every day was difficult. Despite my 64bit 8gig machine you still managed to drag my entire system to a crawl. And I can never just start fresh with you; I think in files and code, but you were always demanding I make projects. I’ve already organize my project into folders on the drive; I’m not interested in duplicating the process for your benefit. But you never listen; it was your way or the highway. You threw a tantrum every time I tried to go around you and open a file directly from explorer.

You often get confused with files that contain a mix of SQL and Coldfusion or HTML, JS, and CF. This kills your code hinting and your syntax highlighter. Speaking of your syntax highlighter: it always dies on larger files, and has horrible refresh lag. I shouldn’t have to wait 30-45 seconds with each tab press when indenting codeblocks. I’ve wasted so much time waiting for you.

But I’ve said to much already. Afterall, its not you: its me. I’ve discovered that I’m more old fashioned than I realized. Despite all your bells and whistles all I really want is an IDE that is responsive. An IDE that will listen to me. All I really need is a solid text editor with syntax highlighting. You’re a lot of great things, but a snappy text editor is not one of them. I can type faster than you can think: and that’s not how it should be.

I don’t know whether I’ll run back to my ex, Dreamweaver, or if I’ll finally get serious with Notepad++, but neither have hesitated when helping me in the past.  Its time to move on. We can try to be friends. Give me a call when Twister comes out.

Sincerely,

-Pirate Gaspard

Coldfusion Monkeys

I found it incredulous that when I searched for “monkey” in Google, not only is http://www.remotesynthesis.com on the 1st page, but it has two *different* links on the 1st page! I realized I was signed into Google+. I signed out and re-searched. The site is no where in the top 10 pages (though www.codinghorror.com is somehow on page 8?).

I am not sure how Google is deciding this. I have “remember web history” turned off on my Google account. Could it be using the information from my contacts in Google+ circles? Many of the people are Coldfusion people. Its the only thing I can think of, unless Google is breaking the rules and using my web history anyway. Anyone have any ideas on this?

Google you try hard, but personalizing my search for funny monkey photos by filtering on Coldfusion? That just isn’t smart. Some things do go together -like chocolate and peanutbutter- but Coldfusion and monkeys do not. …Prove me wrong people, prove me wrong!

Timeout can't be negative wsdl error in Coldfusion

I got an error in Coldfusion today that I had never seen before:

timeout can't be negative

The error occurred when making a call to a webservice. The webservice call was working fine yesterday. I did some Googling but didn’t have much luck in determining why this was happening suddenly.

I traced back over the previous day trying to figure out what I had changed. There was a query that kept timing out, so I had experimented with changing the query timeout setting under the advanced datasource options in cfadmin. Its the only timeout setting I knew of, so I changed it back to its default value of 0. Suddenly my webservice call worked again!

I tried to repeat the error by setting the config back to how it was. But was unable to get the call to fail again.

Re: Coldfusion Strong Encryption: 256bit and higher

Original Article

I’ve put together what I believe is the Java equivalent of CF’s GenerateSecretKey, Encrypt, and Decrypt functions. Unfortunately these encrypt and decrypt functions still do not work in CF7 so there must be something else besides the US_export_policy.jar & local_policy.jar files that would need to be upgraded in order to allow for strong encryption to work in CF7.

I’ve posted the code below in hopes that someone will tell me I’ve made a mistake and that we could get this to work in CF7.

The code is based on this article from Sun.


	
	
	
	
	
	
	



	
	
	
	
	
	
	
	
	



	
	
	
	
	
	
	
	
	

UPDATE: Per Jason Dean’s comment: for this to work in CF7 you need to use a different library. The strong encryption library for CF7 can be downloaded here.

Coldfusion Strong Encryption: 256bit and higher

This does not get enough attention.

Out of the box Coldfusion does not have strong encryption and will not generate keys higher than 128 bits. You must upgrade the underlying Java library in order to gain access to strong encryption. Currently the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 6 download is located here. Download the file, decompress it, and then replace the existing US_export_policy.jar & local_policy.jar files from your Coldfusion install with the ones that you’ve just downloaded. After restarting Coldfusion you will be able to use the GenerateSecretKey function to create keys stronger than 128 bits.

This has been tested to work with CF8 & CF9.

Replacing the files did not cause errors in CF7, but in CF7 the GenerateSecretKey function only takes one argument which is the encryption algorithm and does not allow for a key length to be specified. Perhaps those of you who know java will be able to access the underlying encryption library directly and still get it to work in CF7?

UPDATE: I tried this and it still seems to not work.

UPDATE: Per Jason Dean’s comment below: for this to work in CF7 you need to use a different library. The strong encryption library for CF7 can be downloaded here.