how to prevent the log file was full of exceptions

98 views
Skip to first unread message

Dan Simko

unread,
Sep 1, 2012, 6:20:07 AM9/1/12
to us...@wicket.apache.org, brix-cms...@googlegroups.com
Hi,

I am looking for some solution how to log all exceptions in my code. I tried to override onException method in RequestCycleListener but log file was full of exceptions like this:

org.apache.wicket.protocol.http.servlet.ResponseIOException: ClientAbortException:  java.net.SocketException: Broken pipe

So I am thinking about something like this:

    private static Class[] KNOWN_EXCEPTIONS = {ListenerInvocationNotAllowedException.class, ResponseIOException.class};

    @Override
    public IRequestHandler onException(RequestCycle cycle, Exception ex) {
        HttpServletRequest request = (HttpServletRequest) cycle.getRequest().getContainerRequest();
        if (ex instanceof PageExpiredException) {
            LOG.debug(MessageFormat.format("PageExpiredException for request ''{0}''", request.toString()));
        }else if(isKnownException(ex)){
            LOG.warn(MessageFormat.format("InternalErrorPage for request ''{0}'', Exception message ''{1}''", request.toString(), ex.getMessage()));
        } else {
            LOG.error(MessageFormat.format("InternalErrorPage for request ''{0}''", request.toString()), ex);
        }
        return super.onException(cycle, ex);
    }

    private boolean isKnownException(Exception ex) {
        for (Class<? extends Throwable> clazz : KNOWN_EXCEPTIONS) {
            if(Exceptions.findCause(ex, clazz) != null){
                return true;
            }
        }
        return false;
    }


Is this right approach? If yes, another question is how to deal with this exception:

2012-08-17 09:58:43,184 [http-77.48.124.51-80-32] ERROR c.w.web.WicketRequestCycleListener - InternalErrorPage for request 'http://sportave.com/wicket/resource/com.wickeria.web.WickeriaApplication/jquery-and-wicket-ver-134BD6850DBC85F8DCBCD3A0DB7207C6.js'
java.lang.IllegalStateException: Header was already written to response!
    at org.apache.wicket.protocol.http.HeaderBufferingWebResponse.checkHeader(HeaderBufferingWebResponse.java:64) ~[wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.wicket.protocol.http.HeaderBufferingWebResponse.sendError(HeaderBufferingWebResponse.java:105) ~[wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.wicket.request.http.handler.ErrorCodeRequestHandler.respond(ErrorCodeRequestHandler.java:77) ~[wicket-request-6.0-20120809.004719-1476.jar:6.0-SNAPSHOT]
    at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:814) ~[wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64) ~[wicket-request-6.0-20120809.004719-1476.jar:6.0-SNAPSHOT]
    at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:302) [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:225) [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:281) [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:188) [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:245) [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) [catalina-6.0.35.jar:6.0.35]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina-6.0.35.jar:6.0.35]
    at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) [catalina-6.0.35.jar:6.0.35]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina-6.0.35.jar:6.0.35]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) [catalina-6.0.35.jar:6.0.35]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [catalina-6.0.35.jar:6.0.35]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [catalina-6.0.35.jar:6.0.35]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [catalina-6.0.35.jar:6.0.35]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [catalina-6.0.35.jar:6.0.35]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) [catalina-6.0.35.jar:6.0.35]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) [tomcat-coyote-6.0.35.jar:6.0.35]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) [tomcat-coyote-6.0.35.jar:6.0.35]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) [tomcat-coyote-6.0.35.jar:6.0.35]
    at java.lang.Thread.run(Thread.java:662) [na:1.6.0_26]


Can I prevent this exception? If not, would it be possible to change IllegalStateException to some more specific wicket exception in order to adding it to the KNOWN_EXCEPTIONS array?


Thank you very much!

Korbinian

unread,
Sep 3, 2012, 5:01:51 AM9/3/12
to brix-cms...@googlegroups.com, us...@wicket.apache.org
Hi,

exceptions are usually thrown with a reason - and the main reason why you get so much in your log is that brix with wicket 6 isnt yet finished. Especially the url-sharing part between brix and wicket is quite a problem as brix relies on "full control" of the space while wickt 5 + 6 introduced the concept of multiple url handlers - a concept brix itself never cared for as it was created against 1.4 once and the traversal to wicket 5 and wicket 6 never got finished yed. Especially the introduction of wicket 5 into brix is full of errors. I started to clear out many of them on the 6 branch, but hadn't enough time yet. Beside that I wanted to wait till wicket 6 is released, as programming against dailies is problematic when your low on time.

What brix currently needs is a logic similar to the SSL Url handler in wicket 6, where requests go dont the flow while still the brix handler is the "master" of these requests. I've done that on an experimental
base.

Best,

Kobinian
Reply all
Reply to author
Forward
0 new messages