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

Posted July 13, 2006 at 9:11 AM by Ben Nadel

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:

  • <!--- 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.



Reader Comments

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

Thanks Ben!


Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
May 22, 2013 at 12:44 PM
Ask Ben: Query Loop Inside CFScript Tags
In cf10, if you call a function that has: local.result = {}; local.result.msg = ""; local.svc = new query(); local.svc.setSQL("SELECT * FROM..."); local.obj = local.svc.exe ... read »
May 22, 2013 at 12:29 PM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@Ben: What version of Java are you using? Also, did you test users.id to see what Java reports as the data type? I wonder if it's not a Java primitive data type, but getting returned as something ... read »
May 22, 2013 at 11:47 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@Dana, Awesome - so it looks like this bug was fixed in ColdFusion 10. Thanks so much for double-checking that. ... read »
May 22, 2013 at 11:37 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
When I c&p and run on cf10, I get: Selected User IDs: 1,4 User 1 selected: YES - YES User 2 selected: NO - NO User 3 selected: NO - NO User 4 selected: YES - YES User 5 selected: NO - ... read »
May 22, 2013 at 11:27 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@Tom, Good thought, but no dice. Both of these still exhibit the same behavior: users.id[ users.currentRow ] users[ "id" ][ users.currentRow ] It's just something whacky happening with ... read »
May 22, 2013 at 11:07 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
Could your problem be that "users.id" is actually an ARRAY, not a single value? Perhaps try it again with "users.id[1]" (I only have CF8 here at work). ... read »
May 22, 2013 at 7:52 AM
Nested Views, Routing, And Deep Linking With AngularJS
Hi, Just a quick thank you. As it happens, for my own purposes, the pending ui-router work being done in native angular is likely the one I'll adopt, but your exploration, code and documentation of ... read »
May 22, 2013 at 4:43 AM
How Do You Use The ColdFusion CFParam Tag?
'<cfparam>' or 'isDefined()and <cfset>' performs the same task.Is there any difference? ... read »
InVision App - Prototyping Made Beautiful With Prototyping Tools