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  |  Permalink  |  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
Nov 20, 2009 at 11:32 PM
Five Months Without Hungarian Notation And I'm Loving It
I've used headless camel case for years for not only ColdFusion variables, but also SQL tables and fields... pretty much everything involving code. I also subscribe to the "don't abbreviate and clea ... read »
Nov 20, 2009 at 11:00 PM
Five Months Without Hungarian Notation And I'm Loving It
@Marcel, Yeah, I always err on the side of longer but more readable variable names. As for the camel casing of CF methods and the headless camel casing of custom items, I get around this by always ... read »
Nov 20, 2009 at 10:56 PM
Five Months Without Hungarian Notation And I'm Loving It
I use the following and love it: my.namespace.MyComponents.functionMethodsOrUDF() CONSTANT_VALUES_OR_PROPERTIES One thing I always try is to CamelCaseBuiltInColdFusionFunctions() so others can tell ... read »
Nov 20, 2009 at 5:38 PM
Learning ColdFusion 8: CFImage Part I - Reading And Writing Images
Hi Ben, Great article. I've been looking around to see if ColdFusion image engine can programatically create the following "wrap around" effect: http://www.creativepro.com/article/photoshop-s-she ... read »
Nov 20, 2009 at 5:35 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
@Dave: I talked to Gert he suggested: <cfhttp method="get" url="http://{some cf website}" result="stuff" addtoken="yes" /> Note the addition of cfhttp attribute addtoken. That should persist y ... read »
Nov 20, 2009 at 5:23 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
@Todd, Ahh, gotcha, yeah that makes sense. ... read »
Nov 20, 2009 at 5:17 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
Ben, sorry if I didn't make this clear. You can make it work like that if you want, just put <cfset session.foo = 1> (and <cfset application.foo = 1>) in your OnRequestStart() and it reve ... read »