Archive for the ‘ColdFusion’ Category

Today I needed to view the details for all the scheduled tasks on one of our client’s servers. I needed a print out showing the tasks including the URL, the schedule and whether the task was disabled or not. There were quite a few tasks on this machine, and I wasn’t looking forward to manually going into each task, printing it, and then ending up with a huge stack of printed pages.

So instead I wrote this short script that displays the information I need all in one page.
Continue reading ‘A one page view of scheduled task details’ »

I thought enabling the new ColdFusion 8 server monitor was not supposed to affect your applications, but apparently it can. This morning all of the sudden I could not get one of my coldfusion applications to start, it kept throwing timeout errors in weird, almost random places. When I removed the offending piece of code I would just get a timeout error somewhere else.

I finally tracked it down to the fact that someone enabled the server monitor on this server. Turning it off let the application start up just fine. This is a ModelGlue/ColdSpring application, that may have something to do with it because we had other ColdFusion apps running ok on this same server.

I was able to turn monitoring back on after the application had started. The application scope was only using 3.3kb of memory, much less than some of the other applications. My lone session in the application was taking up 76kb though, which seems kind of high.

Thoughts???

Recently I’ve had a couple occasions where I needed to clean up some data that had non-ascii or high-ascii characters in it. Usually this happens when the data originates from MS Word or Excel. The first time I was producing XML, and was getting errors when I tried to validate my feed. Thats when I noticed I wasn’t using XMLFormat(), which of couse I should be.

I added XMLFormat() around my data, but was still getting errors. Evidently XMLFormat() still leaves in a lot of characters that are just plain illegal in XML. Here is a function I wrote to give me clean data.
Continue reading ‘Cleaning up non ascii chars for XML or other uses’ »

Could it be true? Yes, check out MusicArsenal.com, a new service that allows indie managers and labels to promote their bands. It provides access to all kinds of contacts for setting up shows, radio appearances, etc, as well as organizing all aspects of managing and promoting a band.

It was built in ColdFusion 8, using Model Glue, ColdSpring and Transfer.

The basic account is free so feel free to signup and try it out. The man behind the project is Jimmy Winter, he has a blog at musicarsenal.com/blog/. And you may just bump into him at an NECFUG meeting.

music arsenal

The cfdirectory tag can be pretty slow when reading in large numbers of files. I was trying to read a directory that contained 13,000 files and it was often timing out. In my case, I only needed the names of the files, not the size or date modified or anything else that cfdirectory returns. In that case, specifying the LISTINFO=”name” attribute should speed things up considerably. That tells CF not to stat() each file to get the additional information. Unfortunately this only became available in CFMX 7, and this particular project is running on 6.1

But using java you can achieve the same result:
Continue reading ‘Fast alternative to cfdirectory for large file lists’ »

In a couple application’s I’ve found it necessary to send a user to another ColdFusion server, but still maintain their current session. Usually this is for a payment gateway, or encryption process, or some other kind of functionality that only exists on that other server. In CF5 this was pretty straight forward. You set up both servers to access the same client variables database, then provide an HTML link (or a cflocation tag) that jumps the user to the other server, keeping their CFID and CFToken on the URL. The second server will see those URL values and use them, instead of generating new CFID/CFToken values as it normally would. I had both servers setup something like this:
Continue reading ‘Using CFID and CFToken to jump between ColdFusion servers’ »

There has been some discussion on various ColdFusion discussion lists regarding the maximum heap size you can allocate to ColdFusion/Jrun. Windows allows a process to grab as much as 2GB of contiguous memory. Subtracting out memory for overhead, permgen memory, etc. you are left somewhere with 1.5-1.8GB available for general heap memory.

We were considering moving one of our clients to a Linux server if that would allow us to allocate more memory to the heap. In my research, it seemed the opinions were split about 50/50 as to if Linux would allow us to allocate more than 2GB of memory. So I decided to test for myself. I placed an order for 4GB of memory and waited for them to arrive.

Once I had swapped out my 4 256MB modules for the 4 1GB modules, I increased the heap size (Xms and Xmx options in jvm.config) to 2048 and restarted the server. No problems! I kept increasing by 100mb at a time until I reached 2600 – there it failed to start, so I backed it down to 2500mb. With the permgen and other overhead, Jrun was taking up about 2950Mb of memory – indicating a 3GB limit. I have been running this way for a few days now with no problems.

Your experience may vary of course, depending on what memory options you have in your jvm.config file. I did not need to do anything special other than bump up the Xms and Xmx values.

So the short answer is Yes, you can allocate about 1GB more memory to ColdFusion when running on Linux.

The command line statistics program supplied with ColdFusion, cfstat, has never worked for me. I’ve never tried it on Windows, but I have tried it on Linux on versions 6 and 7, and now version 8.

A little digging around told me why it never worked in CFMX 6-7. Apparently the cfstat script was looking for a particular jar file using a relative path – so it only worked if you were calling it from within the ColdFusion installation directory, which I guess I never did. Looking at the cfstat script in version 8, I can see they specify the full path.

But cfstat still wasn’t working for me in CF8, I got this error message:
Continue reading ‘Getting cfstat to work’ »

On a recent project I needed to be able to rotate PDF documents. I thought for sure there would be something like <cfpdf action="rotate"></cfpdf>, but I was surprised there was no such option. I came across ColdFusion 8′s built in DDX processing feature, and thought I would just do it with that. Turns out the limited DDX engine in ColdFusion does not include the ability to rotate.

But there is a way! The iText class libraries are bundled with ColdFusion, and they are capable of turning your PDFs on end.
Continue reading ‘Rotating PDFs in ColdFusion’ »

Today I needed to get the size of a file I’m working with. If the file was being uploaded from an html form, I can get the file size after calling <cffile action="upload"></cffile> by looking to the cffile.fileSize variable. But in this case, my file was uploaded long ago.

It is possible to get the file size by using <cfdirectory action="list" directory="parentDir"></cfdirectory>. This will return a query containing entries for each file in the directory. One of the columns in the query will be the file size. You can narrow it down to returning only your file by specifying a filter.

<cfdirectory action="list" directory="parentDir" filter="myfile.txt"></cfdirectory>

I don’t know if this filter is applied before or after the directory contents are read in. Anyway I didn’t really like this approach, maybe I’m just spoiled by Ruby’s simplicity ( File.size(“myfile.txt”) ), but this seems like the round about way to get a file’s size.

There is a more elegant way to do it with Java, and its very simple. If we create a Java “file” object, we can call the length() method on that object to get the size of the file in bytes. You can do it in one line.
Continue reading ‘Getting the size of a file in ColdFusion’ »