开发者

Grails Custom Error Page (500) & Tomcat

I'm trying to implement simple custom error page after any U开发者_运维百科nhandled Exception being thrown by the Grails code. I've mapped the 500 to my controller:

    "500" (
        controller: "error",
        action:     "serverError"
    )

and handled the exception in the controller:

def serverError = {
    try {
        // first check, if some exception was reported
        if (!request.exception) {
            return
        }

        // send mail with stack trace if requested
        if (shouldSendErrorReports) {
            log.debug "Mail was sent out successfully..."
        }

    } catch (Throwable e) {
        log.error "Error while reporting an error: " + e
    }

    // redirect to error message
    redirect (
        action: "errorMessage"
    )
}
// lines omitted for clarity

"errorMessage" action is just a simple view, rendering GSP page by default with static content -- information and click-to-redirect window. The page has (I hope) correct prolog:

<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page isErrorPage="true" %>

Now, when testing it locally via NetBeans (Jetty), it all works fine and the errorMessage page is displayed; when deployed to TEST environment (Tomcat6), Tomcat stack-trace is displayed.

How to prevent this Tomcat stack-trace being displayed? I have two thoughts -- first, I'm not really correctly dump-ing (handling?) the Exception, so it bubbles to Tomcat -- second, Tomcat has some configuration value set, so it displays the stack-trace anyway.

Please, if you have any thoughts on this, let me know. Spend some 5 hours figuring this out... :-/

Thank you!


def error = { def exception = request['javax.servlet.error.exception']?.cause?.cause if(exception){

        }       
    }


It's been over a year since you asked this question, but just so others can benefit as well...

Have you tried error-pages-fix plugin? http://www.grails.org/plugin/error-pages-fix

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜