ColdFusion Muse

FQDN for Mail Servers

In this previous post detailing how to manipulate mail headers there was some lively discussion as to whether this was really ethical or not. Just today CF Guru Brian Rideout mentioned that he was having trouble getting ColdFusion mail past a declude filter (a common spam filtering technology supported by many mail servers) due to the mention of ColdFusion in the mail headers. Brian came back and indicated it was actually something else - and his tip bears repeating.

When you specify an email server, either in the CF administrator or in the cfmail tag, make sure you use a fully qualified domain name. It is not advisable to use an IP address here. Remember that many IP addresses you might use are actually "internal" to your network and not public IPs (like 10.1.5.15 or 192.168.1.10 or even 127.0.0.1). When you think about it, it makes sense that declude would hold an IP address against you. It would expect mail to come from a public server. In fact, there are many technologies that analyze the origin - spf, dkim, reverse lookup etc. So make sure and use a real FLQDN - even if you have to edit the hosts file on the server to get it to resolve :).

Threads Not Terminating on ColdFusion 8.0.0

Over the past few days on CF Talk Ian Skinner has been struggling tuning an application that makes use of CFTHREAD. In his application a process spawns threads for creating report files. Ian Reports that the process would spawn the threads, but the threads themselves would neither complete gracefully nor respond to a "terminate" action (<cfthread action="terminate" ...>). No suggestions from the muse or anyone else seemed to help. Finally he upgraded to ColdFusion 8.0.1 and the problem appears to be resolved. Threads complete gracefully without hanging around.

Nothing in the 8.0.1 release notes raises any red flags with me that would indicate why updated to 8.0.1 resolved the issue. I suspect that something very specific about his JVM was causing it. Still, it's nice to know if you run into this ticklish issue there is a way around it.

CFCs, the Variables Scope, and the Application Scope

It's pretty common to use the application scope to cache components. If your component is a collection of methods or data access functions it's often faster to put them into the application scope than it is to create an instance with each request. Now you probably know that you should quality all of the variables in a function with the "var" key word. This insures that the variable exists inside the "scope" of the function call. This allows multiple function calls to be made to the same instance without one set of variables over writing the other.

One of the areas where this can be difficult to manage is when using a ColdFusion tag that creates its own scope. Take CFHTTP as an example.

[More]

Coldfusion 8's Catch 22 - Web 2.0 Widgets

Recently a colleague was lamenting the fact that the rich text editor that ships with CF8 seems to load slowly and have a few other problems that are causing consternation for his users. His exact comment was that he wished Adobe would "fix" or "patch" the FCK editor that underpins the rich text editor. I certainly sympathize with his desire to fix the behavior he is experiencing for his users, but I would hasten to point out that the underlying libraries for FCK editor are not from Adobe. Instead, along with copies other script libraries for Ajax, window behaviors and the like, they are open source libraries - many of them from Yahoo.

Of course this is one of the bugaboos of these new "client side" widgets that ship with Coldfusion 8 and in a way they put Adobe in a difficult position. In CF8, Adobe encapsulated a bunch of cool client side functionality into new tags like cfwindow, cfajax, the rich text editor etc. This is not new for Coldfusion - cfform, cfgrid, etc have been around for since the beginning. The biggest difference is that there is a lot more of them and they are exponentially more capable with the advent of Ajax, binding, and Cfajaxyproxy. In fact, Ajax and Cfajaxproxy really continues the trend of blurring the line between the server and the browser - a trend already in full fury in the Flex world. Adobe is seemingly caught between the two worlds of client and server.

[More]

Troubleshooting a Leaky Heap in Your JVM

The phrase "memory leak" can cause shivers to run down the spine of the most seasoned developer. Having some process on your server that is gloaming onto memory and failing to release it is a guaranteed all nighter lurking somewhere in your future. Recently we were debugging a new, soon to be released application. We discovered what looked like a memory leak. The JVM memory used would climb steadily toward the maximum heap size. When the runtime garbage collection kicked in it would reduce the memory only by about a third of the increase. So, for example, memory use would climb from 300 megs to 600 megs and then GC would reduce usage back to 500 megs and so on. This situation would inevitably lock up the server with out of memory errors. What follows is a recap of our troubleshooting journey.

[More]

Coldfusion 8 Upgrade and FDS

I'm not a huge fan of upgrading software. I have found, in the words of Sam Gamgee's gaffer, that "Short cuts make long delays." In my view you will usually save time troubleshooting by doing a full install rather than an upgrade. Recently we needed to upgrade a customer from Coldfusion 7 to Coldfusion 8. It was a single server installation and we needed a minimum of downtime so, after writing a rollback plan and prepping the server we chose the "upgrade". All seemed to go well. All the data sources, services and settings ported over to the new Coldfusion 8 installation and the server fired up just fine. We thought we were home free until....

[More]

Cfexecute: Upgrading from Coldfusion 6.1 to Coldfusion 8

Here's a tricky little bug that I missed during a recent upgrade. The customer had Coldfusion 6.1 and we were tasked with moving them to Coldfusion 8. After reviewing the code and determining that no changes would be necessary, we did the upgrade. After we were finished everything seemed fine except one obscure task that was set up to run periodically. It was a command line task using Cfexecute. The task accessed the mysqlump.exe file to create periodic backups of the mysql database. The code (which was working on CF 6.1) looked like this:

<cfexecute
    name="#pathvar#/mysqldump.exe --opt #var1# --user=#var2# --password=#var3#"
    outputFile="#var4#"
    timeout="120">

</cfexecute>
Now I'm not a huge fan of cfexecute. I usually find some other way to run command line programs. But I have seen code exactly like this work before so I did not think to check the syntax. After the upgrade we began to get a "file not found" type of error. We looked at file permissions. We changed the path to remove spaces. We even tried the Joliet style path and name (as in c:\progra~1\....) but to no avail. Our customer, a Coldfusion programmer in his own right, was looking through the docs and noticed that the "arguments" attribute was a part of the docs but missing in our previously working example. He changed the code to look like this:
<cfexecute
    name="#pathvar#/mysqldump.exe"
    arguments="--opt #var1# --user=#var2# --password=#var3#"
    outputFile="#var4#"
    timeout="120">

</cfexecute>
...sure enough it started working.

So if you are troubleshooting Cfexecute after an upgrade to 7 or 8 and you are getting missing file exceptions and scratching your head. Check to see if you are using the old style Cfexecute syntax where the executable and the arguments are all on the same line and passed in the "name" argument. If you are, take the "arguments" portion of the command line and move them to the "arguments" attribute of the cfexecute tag. That might do the trick.

Moron Casting... I Mean "More on Casting"

In previous posts I have lauded the "new" ability of the Javacast function to handle arrays of primitive objects. David Stamm pointed out that javacast is capable of handling complex java types as well - and you can cast them as arrays! In his example he used the "java.net.URL" class and created an array of them, then cast the whole thing as an array of complex java objects. I'll show you his working example in a moment, but first let's talk about why would you ever need this?

If you are working with Java libraries there are many times that they require as an argument an array of objects of a certain type. Let's say you have a payroll system written in Java and one of the functions is "runPayroll()". This function takes an array of employee objects. To keep it simple let's just say that each employee object contains properties for pay amount and vacation accrual. Internally, runPayroll() loops through the employees and calls emp.getPayAmt() and emp.getAccrual() and populates some batch job or whatever. This is fairly standard stuff in Java. If you wanted to make use of the runPayroll() function how would you accomplish it?

[More]

CFC Wrapper for 2D Barcodes Released

I have had a great many readers calling me and asking about the 2D barcode CFC mentioned in a recent post. You will be happy to know that it has been released. You can use this CFC to create 2D barcodes for printing and to read 2D barcodes containined in images. You can find the download link and read more about it on Ryan's blog. Keep in mind that the CFC is specific to CF8 and it uses a commercial (albeit inexpensive) Java library from Java4Less. Ryan and I would both be interested in any reviews or comments. If you end up using the tag we'd love to hear some follow-up on how it is being used.

Handling Faxes and 2D Barcodes in Coldfusion 8

I have a secret that has nothing to do with underwear. People think I'm pretty smart but the truth is that I'm surrounded every day by talented developers who know how to solve problems and find innovative solutions. Just rubbing shoulders with people like that tends to increase my level of knowledge and ability. Among those people is Ryan Stille, a Coldfusion and Linux Guru who has added tremendously to the wealth of knowledge here at CF Webtools. In the last few days Ryan has managed to piece together a cost effective and innovative solution for a customer who wishes to handle incoming faxes in Coldfusion. Eventually he will post a CFC on his blog - but meanwhile I wanted to explain the problem and the elegant solution involved.

[More]

Iterations, Comparisons and JavaCast (Oh My)

Testing Gurus like Dave Watts and Robi Sen will tell you that iterative tests are only interesting in a passing academic sort of way. Indeed if you are testing a real world application don't bother setting up a fancy-pants loop with 50,000 iterations to see if you should use "IS" or "EQ". If you are going to test then take the time to test real world operations in your application. But while we are on the subject of iterative tests I got to pondering what goes on under the hood. For example, what happens when you do "var1 IS var2" in a CFIF.

[More]

Cast Your Java Arrays Upon the Water and They Shall Return in Due Season

If you have ever had to use a Java Widget from inside of your Coldfusion page you might know about the Javacast() function. Javacast allows you to bind a variable to one of Java's primitive "types" like string, long, float etc. Why is Javacast() necessary? I'm glad you asked. In the old days of Coldfusion 4 and 5, CF treated any variable as a sort of mystery meat. It didn't look too closely at it until you chose to do something with it. Only when an operation required a variable to have the properties of a certain type did Coldfusion complain. This is still true to a large extent today.

If you have a URL variable called "total" that is supposed to contain a number, you can populate it however you wish. You can put the string "sasquatch" in it for example. Coldfusion will ignore the type and pass the variable along right up until you try to add shipping to it, or divide it by another number or something. Only then will Coldfusion throw an error. Of course, using CFCs allows you far more control over the "type" of variables in play - but you can still treat your variables in this "weakly typed" way if you wish.

Java, on the other hand, is a strongly typed language. Variables are defined as "new" this and "new" that - where the this and that are classes or objects with methods and properties. So things written in Java don't take just anything for arguments to worry about at runtime. Javacast() was invented to convert Coldfusion variables into specific java types that Java methods are expecting. Take the following as example:

[More]

Cfwindow Positioning Trial and Error

I love the new widgety stuff in Coldfusion 8. The Cfwindow tag caught my attention right away. it seemed like a quick and easy way to frame content on a page and make it manageable. For example, I had a list of items that appear on the home page of our tracking system. It's the "hotlist" - a list of open and active work orders and projects. I decided to use Cfwindow to make it draggable and re-sizable. It was easy.

<cfwindow
        height="475"
        resizable="True"
        initshow="True"
        x="380"
        y="150"
        closable="False"
        draggable="True"
        title="Hot List"
        name="hotlist"
        headerstyle="background-color: ##A7B3C2;">

Some looping code that outputs a list of links.
</cfwindow>
This worked splendidly. I ended up with exactly what I wanted - a nice scrolling window that was easy to drag and resize to accommodate more entries.

Since I loved the little drop shadow thingy I decided I would use it on the right hand side menu as well - just to frame in the menu with a header. Oops... this turned out to be quite difficult. Why? Because there is no way to anchor the window to the layout. The layout is dynamic on the right. The right hand menu "clings" to the right side of the screen - meaning the X and Y coordinates are different for each screen size. But the Cfwindow appears over whatever is on the screen and the "x" and "y" coordinates make it's position absolute. I went hunting for an answer.

[More]




Blog provided and hosted by CF Webtools. Blog Sofware by Ray Camden.