Invalid token '\n' found on line 452 at column 0

Posted July 13, 2006 at 9:11 AM

Tags: ColdFusion, Work

You ever get this ColdFusion error telling you that you can't have a line break at the end of your document? And then you start deleting extra white space having the ColdFusion compiler tell you that whatever your last document character is, it's invalid? This is an extremely frustrating ColdFusion error because it doesn't really tell you what's going on - if you don't really read the error information!

An invalid token error get thrown when ColdFusion is trying to finish parsing a TAG and either runs out of data (such as the end of the file) or hits a character (token) that is not allowed. For example, this:

 Launch code in new window » Download code as text file »

  • <!--- This is a ColdFusion comment -->

... will throw an invalid token error when it hits the end of the file. Check out the open/close comments. The starting one is a ColdFusion comment tag opener but the ending one is an HTML comment tag closer. ColdFusion obviously ignores the closing comment as it doesn't care about HTML comments and continues parsing through the document looking for a closing comment tag (--->). Then, when it hits the end of the document without finding a closing comment tag it throws the error:

Invalid token 'X' found on line Y at column Z

... where X, Y, and Z are just variants (x = token, y = line, z = column).

While the "message" of the error is crap, please READ READ READ the rest of the ColdFusion error notes. The fine print will usually tell you what's going wrong. For instance, the above error will have this bullet:

The closing tag for the CFML comment is missing. Comment begins on line 267.

It's that easy. I know a lot of the times we see error messages and just start diving in, trying to fix things. But, why waste all that time when the debugging tells you exactly where the error is.

Download Code Snippet ZIP File

Post Comment  |  Ask Ben  |  Other Searches  |  Print Page



Learning ColdFusion 9 - ColdFusion 9 tutorials, samples, examples, demos

Reader Comments

Apr 24, 2009 at 10:26 AM // reply »
1 Comments

Thanks Ben!


Post Comment  |  Ask Ben

Recent Blog Comments
Mar 19, 2010 at 9:29 AM
Be Careful When Including Images In jQuery Auto-Suggest
@Jim, I've only ever messed with the config in FireFox. Not sure what's available in the other browsers. ... read »
Mar 19, 2010 at 9:27 AM
ColdFusion 8 ImageDrawTextArea() (Inspired By Barney Boisvert!)
@Martin, It's been a while since I looked at this; but, I don't think I handled explicit line breaks because it just made the calculations harder. Perhaps in another version. ... read »
Mar 19, 2010 at 9:23 AM
Ask Ben: Parsing CSV Strings With Javascript Exec() Regular Expression Command
@Jens, Ahh, gotcha. Yeah, the textarea is probably gonna be safe cross-browser. ... read »
Mar 19, 2010 at 9:22 AM
How ColdFusion CreateObject() Really Works With Java Objects
@Dmitry, Word up - createObject() can do a whole bunch of things. It's probably one of the best updates to the language. ... read »
Mar 19, 2010 at 9:19 AM
Learning ColdFusion 9: Resetting Applications With ApplicationStop()
@Rocky, Yeah, I assume it will flush all application-scope variables when you can applicationStop(), regardless of where they are initialized. As far as the connectivity between application and s ... read »
Mar 19, 2010 at 9:15 AM
Ask Ben: Getting The Start And End Dates Of The Previous Week In ColdFusion
@David, It gets the last week. I goes back 7 days, and then finds the start / end of that week. ... read »
Mar 19, 2010 at 9:12 AM
Using Inline List Elements
@ben: thank you very much - that helped me a lot ;) ... read »
Mar 19, 2010 at 9:10 AM
Ask Ben: Selecting XML Attributes Given Other XML Attributes
@Tom, That's odd. Looks like a malformed XML problem. Make sure you aren't missing any of the ">" closing brackets or something. ... read »