You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Entropy <bl...@gmail.com> on 2014/10/25 00:39:03 UTC

Wicket error page runs twice

I have a requirement that when certain kinds of exceptions are thrown, I want
to customize my exception error page.  I stuffed the exception into the
requestcycle and retrieve it in the page like so:

Exception exception =
getRequestCycle().getMetaData(ESPApplication.EXCEPTION_KEY);

I watch through breakpoints or log statements and the exception is provided
the first time through, but after it processes it, the error page runs a
second time, this time with a null in that value.  the result is that my
error page is not getting what it needs, and renders without the needed
info.

Why would the error page run twice?  I don't see any additional exceptions
in the log, and the error page does render...it just renders as if the
exception object were null.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-error-page-runs-twice-tp4668093.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket error page runs twice

Posted by Entropy <bl...@gmail.com>.
With a slight modification, that worked.  I used:

return new RenderPageRequestHandler(new PageProvider(new
ESPApplicationErrorPage(ex))); 

Thanks Martin!

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-error-page-runs-twice-tp4668093p4668115.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket error page runs twice

Posted by Martin Grigorov <mg...@apache.org>.
On Mon, Oct 27, 2014 at 2:35 PM, Entropy <bl...@gmail.com> wrote:

> Okay, I found this, the first request URL and query string are:
>
>
> /EquitableSharing/?19-1.IBehaviorListener.1-share-form-toolContainer-declineSharingButton
>
> The second is:
>
>
> /EquitableSharing/wicket/bookmarkable/gov.usdoj.afms.esp.application.ESPApplicationErrorPage
>
> So it seems like even though the error page RUNS in the first request,
> wicket is trying to redirect to it in order to make the URL bookmarkable.
> Of course, nobody wants a bookmarkable error page, that would just be
> silly.
> So I must be triggering this behavior by accident somewhere.
>
> The error page itself just extends WebPage.  In the app init, the error
> page
> is set up like so:
>
>             // set the error page
>             IApplicationSettings settings = getApplicationSettings();
>             settings.setInternalErrorPage(ESPApplicationErrorPage.class);
>             this.getRequestCycleListeners().add(new
> AbstractRequestCycleListener(){
>                 public IRequestHandler onException(RequestCycle cycle,
> Exception ex) {
>                         cycle.setMetaData(EXCEPTION_KEY, ex);
>                                 return null;
> //cycle.getRequestHandlerScheduledAfterCurrent();
>

instead:
return new RenderPageRequestHandler(new ESPApplicationErrorPage(ex));


>                 }
>
>             });
>
>
> getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);
>
> We have some calls to mountPage in the app init, but the error page is not
> involved.  Where is this behavior coming from I wonder?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-error-page-runs-twice-tp4668093p4668113.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Wicket error page runs twice

Posted by Entropy <bl...@gmail.com>.
Okay, I found this, the first request URL and query string are:

/EquitableSharing/?19-1.IBehaviorListener.1-share-form-toolContainer-declineSharingButton

The second is:

/EquitableSharing/wicket/bookmarkable/gov.usdoj.afms.esp.application.ESPApplicationErrorPage

So it seems like even though the error page RUNS in the first request,
wicket is trying to redirect to it in order to make the URL bookmarkable. 
Of course, nobody wants a bookmarkable error page, that would just be silly. 
So I must be triggering this behavior by accident somewhere.

The error page itself just extends WebPage.  In the app init, the error page
is set up like so:

	    // set the error page
	    IApplicationSettings settings = getApplicationSettings();
	    settings.setInternalErrorPage(ESPApplicationErrorPage.class);
	    this.getRequestCycleListeners().add(new AbstractRequestCycleListener(){
	    	public IRequestHandler onException(RequestCycle cycle, Exception ex) {
	    		cycle.setMetaData(EXCEPTION_KEY, ex);
				return null; //cycle.getRequestHandlerScheduledAfterCurrent();
	    	}

	    });
	   
getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);

We have some calls to mountPage in the app init, but the error page is not
involved.  Where is this behavior coming from I wonder?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-error-page-runs-twice-tp4668093p4668113.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket error page runs twice

Posted by Martin Grigorov <mg...@apache.org>.
http://central.maven.org/maven2/org/apache/wicket/wicket-core/6.12.0/wicket-core-6.12.0-sources.jar

Hint: org.apache.wicket.settings.IRequestCycleSettings.RenderStrategy

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Mon, Oct 27, 2014 at 2:20 PM, Entropy <bl...@gmail.com> wrote:

> Well, you are definitely right that there are multiple requests for
> whatever
> reason.  I can see WicketServlet doPost called, the method runs, throws the
> error, the error page gets control with the exception, then a doGet occurs
> and the error page runs again without the exception.
>
> I can't really see the details as I don't have the source for Wicket
> 6.12.0.
> I went to http://www.apache.org/dyn/closer.cgi/wicket/6.12.0 and none of
> the
> links work.  Where can I download 6.12.0 source so I can attach it to my
> debugger?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-error-page-runs-twice-tp4668093p4668111.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Wicket error page runs twice

Posted by Entropy <bl...@gmail.com>.
Well, you are definitely right that there are multiple requests for whatever
reason.  I can see WicketServlet doPost called, the method runs, throws the
error, the error page gets control with the exception, then a doGet occurs
and the error page runs again without the exception.

I can't really see the details as I don't have the source for Wicket 6.12.0. 
I went to http://www.apache.org/dyn/closer.cgi/wicket/6.12.0 and none of the
links work.  Where can I download 6.12.0 source so I can attach it to my
debugger?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-error-page-runs-twice-tp4668093p4668111.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket error page runs twice

Posted by Martin Grigorov <mg...@apache.org>.
On Mon, Oct 27, 2014 at 1:26 PM, Entropy <bl...@gmail.com> wrote:

> The exception occurred within an AjaxButton.  In this case, a service was
> not
> responding, we want to show our error page, and put a custom message up
> indicating that it is a service problem, call the help line or try again
> later blah blah blah...
>
> I don't think any redirects are involved.
>

Better check with the browser's Dev tools.
Or put a breakpoint at WicketFilter#doFilter().


>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-error-page-runs-twice-tp4668093p4668109.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Wicket error page runs twice

Posted by Entropy <bl...@gmail.com>.
The exception occurred within an AjaxButton.  In this case, a service was not
responding, we want to show our error page, and put a custom message up
indicating that it is a service problem, call the help line or try again
later blah blah blah...

I don't think any redirects are involved.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-error-page-runs-twice-tp4668093p4668109.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket error page runs twice

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

It seems like the error page is being rendered after a redirect. That's why
the request cycle is empty, because it is a new one.
On Oct 25, 2014 1:42 AM, "Entropy" <bl...@gmail.com> wrote:

> I have a requirement that when certain kinds of exceptions are thrown, I
> want
> to customize my exception error page.  I stuffed the exception into the
> requestcycle and retrieve it in the page like so:
>
> Exception exception =
> getRequestCycle().getMetaData(ESPApplication.EXCEPTION_KEY);
>
> I watch through breakpoints or log statements and the exception is provided
> the first time through, but after it processes it, the error page runs a
> second time, this time with a null in that value.  the result is that my
> error page is not getting what it needs, and renders without the needed
> info.
>
> Why would the error page run twice?  I don't see any additional exceptions
> in the log, and the error page does render...it just renders as if the
> exception object were null.
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-error-page-runs-twice-tp4668093.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>