We are doing a rather Humongous Flex Project here and cfwebtools, one that involves using RemoteClass in flex, to tie our Backend objects to our front end objects.

I’m using coldfusion in an Object Oriented Programming (OOP) fashion, where in many situations, your objects invoke one another using (createObject) or something along those lines.

I’ve gotten used to flex, and in flex it is common in certain situations to declare your variables with a default value. For instance:

private var acData:ArrayCollection = new ArrayCollection()

I’ve took the same approach in my cfc, where I have many variables in my cfc that I give initial values to. For Instance:

variables.file_id = 0;
variables.href = ”;
variables.name = ”;
variables.rawFile = xmlNew();
variables.type = ‘FileVO’;

If you notice I declare my xmlNew() and I then later in the file have getters and setters (accessors / mutators) that accept the appropriate variables… I then tie this object back to my actionscript object, using the RemoteClass Metadata (tag, I use tag very loosely here, i’m not sure on the for sure term…)

In my actionscript object, I have a variable called “rawFile” the same one that my cfc holds. In my .as file I declare the rawFile as:

public var rawFile:XML;

so now that I’ve tied the actionscript object back to my cfc, I would only expect that I have to create the xmlNew() to send back a valid xml document to my .as object.

Premature end of file

When ever I did this, coldfusion still seemed to process, I could run dumps, and then abort, and then take the dumps out, and would never see an error… but when I tried to invoke it from flex I would trace the (event.fault.faultString) that comes back from the remote object, and I would see there error ‘Premature end of file’… thinking it was one of my higher cfc’s I spent the better part of a week debugging this non descriptive issue. It never made sense because as far as dumping things on the coldfusion side, I NEVER GOT THE ERROR. but when I used flex, I did… I went through the ranting and raving at the office for many many hours, I just couldn’t understand why it was failing, come to find out… (it makes well enough sense to me now, but I didn’t even think you would need a root node in the xml)

Just because the xmlNew() function creates a valid xml document object, it doesnt create a root node, and every xml file must have a root node, thats just a general rule of xml… I felt pretty stupid after this one, but at the same time… I was testing all of my other cfc’s trying to figure out exactly where this error was coming from… because my cfc’s get created as object by each other, the debugging is so obtrusive, and I just couldn’t see what I needed out of dumping data. I just don’t think things are quite there yet for coldfusion, and using it as an object oriented language… Coldfusion is great because you can make many things possible soo very easy, but because of it’s loosely typed nature… its hard to debug cfc’s when they get created from one another… it all seems like the parent cfc is the problem, when maybe it’s a child cfc…

When I have a parent cfc, invoking a child cfc, then that child invokes another child, and that child may invoke 3 or 4 children, you don’t know where to start when the only error you see is ‘Premature end of file’ and coldfusion isn’t failing other wise… so you just start at the top and dwindle down… because i started at the top, I would make a change, then test, and go through the standard debugging… but nothing ever fixed it…

finally I found a tool called cfcFlexplorer and it didnt necessarily fix the issue, but it gave me a better view of my cfc’s and an easier view to all the methods within them, then it also let me invoke them, and see an actual dump of the data… that helped me narrow the problem down, and I then found out the big issue…

When using xmlNew() in coldfusion, make sure you at least using or something along those lines to create a root node…

<cfxml variable=“xmldoc”>

Just so you don’t bang your head against the wall like I did…

RANTING AND RAVING IS DONE! i’m so glad this issues is fixed