Second Agent-J solution looks fine.
I just want to provide single operation sequence for any possible 404 response. setStatusCode() or etc. could be placed to a action's method, but the names of the action and controller are not wanted by me to be written for any 404 need.
I think that not found handling could be implemented a bit better in the framework. Lets remember auto not found for unmatched route but need of user implemented one for matched route and unfounded controller.
According to the specification, the 404 response is sent for any request doesn't provide any data to response. This could be service links (ajax-only) or private/protected app parts accessed by GET, invalid route params, unfounded controller/action, unfounded file, many special realization-related cases like unfounded post/message/user or any other data in database and so on and so on.
And current "errors system" isn't very handy to provide good solution for some part of this cases.
Yes, problem could be solve some way with current capabilities, but it would looks like "crutches" (as such ways called in russian community =)