Avoiding “Method code too large” error with CFWheels and ColdRoute..

I recently hit a major snag with a 1,200 line config/routes.cfm with Lucee 4.5 throwing a nasty "Method code too large" exception..

After the wave of panic had subsided.. the fix was relatively simple. By the grace of Odin, coldroute’s drawRoutes() function can be called multiple times and results in the same routes structure as if it were called a single time.

I split my monstrous routes file into smaller includes located in a new config/routes directory, then simply included them in the main config/routes.cfm


  .get(to="admin.Foo##index", name="fooIndex", pattern="admin/foo")
  .post(to="admin.Foo##update", name="fooUpdate", pattern="admin/foo/update/[key]")


  .get(to="public.Pages##index", name="pagesIndex", pattern="/pages")
  .post(to="public.Pages##show", name="pagesShow", pattern="/pages/show/[key]")


  .get(to="users.Bar##index", name="barIndex", pattern="/bars")
  .get(to="users.Bar##new", name="barNew", pattern="/bars/new")

And simply include in the main routes  like so:


include "routes/admin.cfm";
include "routes/public.cfm";
include "routes/user.cfm";
// default routes

I hope this saves you that wave of panic..


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s