You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Christian Huber <hu...@butterbrot.org> on 2011/10/01 16:29:12 UTC

Re: How to handle errors in RequestCycle.onEndRequest

Hi again,

unfortunately my problem still persists. After migrating to 1.5.1 and 
putting my commit code into  onRequestHandlerExecuted() the error 
messages generated there are still not propagated to the rendered 
response page.

But instead I now get the following error message:

ERROR - DefaultExceptionMapper     - Unexpected error occurred
java.lang.IllegalStateException: Header was already written to response!

So it seems that at this it is still to late to anything to the current 
response.

As before the error messages do get displayed after the following request.

At the moment I am totally stumped. Does anyone have a clue what I am 
doing wrong here?

Thanks, Chris


The Sanity Resort <http://sanityresort.blogspot.com/>

Am 24.09.2011 17:18, schrieb Igor Vaynberg:
> use the onRequestHandlerExecuted() to commit the transaction and
> onException() to roll it back. these are both in
> IRequestCycleListener.
>
> -igor
>
> On Mon, Sep 19, 2011 at 10:50 AM, Christian Huber<hu...@butterbrot.org>  wrote:
>> Hi all,
>>
>> I just noticed that exceptions occuring in onEndRequest of a RequestCycle
>> somehow do not reflect on the respone page.
>>
>> I am using an AjaxFallbackButton and the OSIV pattern and thus commit my
>> database changes in onEndRequest, now if an exception occurs here I do get a
>> log entry but I cannot get my application to display the corresponding error
>> to the user.
>>
>> Adding a message to the feedback panel does not help as the message gets
>> displayed on the following request but not the current one. I also tried
>> using various AbortExceptions like RedirectToUrlException,
>> RestartResponseException or AbortWithWebErrorCodeException. This did improve
>> the situation as far as the request did get aborted but there is still no
>> visual display of the error.
>>
>> Setting the ResponsePage directly and/or setting redirect to true did not
>> change anything.
>>
>> This sounds like a common problem and so I guess there is an easy solution
>> to it, but I just don't get it right now, so any pointers are welcome.
>>
>> Thanks, Chris
>>
>> --
>> The Sanity Resort<http://sanityresort.blogspot.com/>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

Re: How to handle errors in RequestCycle.onEndRequest

Posted by Christian Huber <hu...@butterbrot.org>.
Sorry, took a while until I got time to test the changes. WIth the 
current trunk revision I now can use restart exceptons within 
onRequestHandlerExecuted to force a redirect to an error page and even 
adding feedback messages seems to work properly.

Thank you very much for this fix! :-)


The Sanity Resort <http://sanityresort.blogspot.com/>

Am 12.10.2011 08:31, schrieb Igor Vaynberg:
> ive just checked in a couple of tweaks, give it a go...
>
> -igor
>
> On Sat, Oct 1, 2011 at 10:38 AM, Christian Huber<hu...@butterbrot.org>  wrote:
>> Hi Igor,
>>
>> I just saw you answered to my JIRA issue. I had tried your suggestion about
>> throwing an exception before but to no avail (see also my comment on the
>> issue):
>>
>> I had tried adding
>>
>> throw new RestartResponseException(ErrorPage.class);
>>
>> to the onrequesthandlerexecuted() callback while ErrorPage is just an empty
>> page with empty markup and mounted at "error" (calling that page did work
>> when the exception was not thrown) but that caused the following error:
>>
>> ERROR - DefaultExceptionMapper - Unexpected error occurred
>> org.apache.wicket.RestartResponseException
>> ERROR - DefaultExceptionMapper - Unexpected error occurred
>> java.lang.IllegalStateException: Header was already written to response!
>>
>> throwing the exception directly in the homepage constuctor got me redirected
>> to the error page as expected.
>>
>> would you need a new quickstart for this?
>>
>>
>> The Sanity Resort<http://sanityresort.blogspot.com/>
>>
>> Am 01.10.2011 17:54, schrieb Christian Huber:
>>> quickstart created and added to
>>> https://issues.apache.org/jira/browse/WICKET-4103
>>>
>>> this quickstart does not behave exactly like my application but the
>>> primary problem about messages not being displayed is reproducable. please
>>> let me know if i can provide any further information and thank you for your
>>> assitance.
>>>
>>>
>>> The Sanity Resort<http://sanityresort.blogspot.com/>
>>>
>>> Am 01.10.2011 16:47, schrieb Igor Vaynberg:
>>>> that sounds like a bug, please create a quickstart and attach it to jira.
>>>>
>>>> -igor
>>>>
>>>> On Sat, Oct 1, 2011 at 7:29 AM, Christian Huber<hu...@butterbrot.org>
>>>>   wrote:
>>>>> Hi again,
>>>>>
>>>>> unfortunately my problem still persists. After migrating to 1.5.1 and
>>>>> putting my commit code into  onRequestHandlerExecuted() the error
>>>>> messages
>>>>> generated there are still not propagated to the rendered response page.
>>>>>
>>>>> But instead I now get the following error message:
>>>>>
>>>>> ERROR - DefaultExceptionMapper     - Unexpected error occurred
>>>>> java.lang.IllegalStateException: Header was already written to response!
>>>>>
>>>>> So it seems that at this it is still to late to anything to the current
>>>>> response.
>>>>>
>>>>> As before the error messages do get displayed after the following
>>>>> request.
>>>>>
>>>>> At the moment I am totally stumped. Does anyone have a clue what I am
>>>>> doing
>>>>> wrong here?
>>>>>
>>>>> Thanks, Chris
>>>>>
>>>>>
>>>>> The Sanity Resort<http://sanityresort.blogspot.com/>
>>>>>
>>>>> Am 24.09.2011 17:18, schrieb Igor Vaynberg:
>>>>>> use the onRequestHandlerExecuted() to commit the transaction and
>>>>>> onException() to roll it back. these are both in
>>>>>> IRequestCycleListener.
>>>>>>
>>>>>> -igor
>>>>>>
>>>>>> On Mon, Sep 19, 2011 at 10:50 AM, Christian
>>>>>> Huber<hu...@butterbrot.org>
>>>>>>   wrote:
>>>>>>> Hi all,
>>>>>>>
>>>>>>> I just noticed that exceptions occuring in onEndRequest of a
>>>>>>> RequestCycle
>>>>>>> somehow do not reflect on the respone page.
>>>>>>>
>>>>>>> I am using an AjaxFallbackButton and the OSIV pattern and thus commit
>>>>>>> my
>>>>>>> database changes in onEndRequest, now if an exception occurs here I do
>>>>>>> get a
>>>>>>> log entry but I cannot get my application to display the corresponding
>>>>>>> error
>>>>>>> to the user.
>>>>>>>
>>>>>>> Adding a message to the feedback panel does not help as the message
>>>>>>> gets
>>>>>>> displayed on the following request but not the current one. I also
>>>>>>> tried
>>>>>>> using various AbortExceptions like RedirectToUrlException,
>>>>>>> RestartResponseException or AbortWithWebErrorCodeException. This did
>>>>>>> improve
>>>>>>> the situation as far as the request did get aborted but there is still
>>>>>>> no
>>>>>>> visual display of the error.
>>>>>>>
>>>>>>> Setting the ResponsePage directly and/or setting redirect to true did
>>>>>>> not
>>>>>>> change anything.
>>>>>>>
>>>>>>> This sounds like a common problem and so I guess there is an easy
>>>>>>> solution
>>>>>>> to it, but I just don't get it right now, so any pointers are welcome.
>>>>>>>
>>>>>>> Thanks, Chris
>>>>>>>
>>>>>>> --
>>>>>>> The Sanity Resort<http://sanityresort.blogspot.com/>
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

Re: How to handle errors in RequestCycle.onEndRequest

Posted by Igor Vaynberg <ig...@gmail.com>.
ive just checked in a couple of tweaks, give it a go...

-igor

On Sat, Oct 1, 2011 at 10:38 AM, Christian Huber <hu...@butterbrot.org> wrote:
> Hi Igor,
>
> I just saw you answered to my JIRA issue. I had tried your suggestion about
> throwing an exception before but to no avail (see also my comment on the
> issue):
>
> I had tried adding
>
> throw new RestartResponseException(ErrorPage.class);
>
> to the onrequesthandlerexecuted() callback while ErrorPage is just an empty
> page with empty markup and mounted at "error" (calling that page did work
> when the exception was not thrown) but that caused the following error:
>
> ERROR - DefaultExceptionMapper - Unexpected error occurred
> org.apache.wicket.RestartResponseException
> ERROR - DefaultExceptionMapper - Unexpected error occurred
> java.lang.IllegalStateException: Header was already written to response!
>
> throwing the exception directly in the homepage constuctor got me redirected
> to the error page as expected.
>
> would you need a new quickstart for this?
>
>
> The Sanity Resort <http://sanityresort.blogspot.com/>
>
> Am 01.10.2011 17:54, schrieb Christian Huber:
>>
>> quickstart created and added to
>> https://issues.apache.org/jira/browse/WICKET-4103
>>
>> this quickstart does not behave exactly like my application but the
>> primary problem about messages not being displayed is reproducable. please
>> let me know if i can provide any further information and thank you for your
>> assitance.
>>
>>
>> The Sanity Resort <http://sanityresort.blogspot.com/>
>>
>> Am 01.10.2011 16:47, schrieb Igor Vaynberg:
>>>
>>> that sounds like a bug, please create a quickstart and attach it to jira.
>>>
>>> -igor
>>>
>>> On Sat, Oct 1, 2011 at 7:29 AM, Christian Huber<hu...@butterbrot.org>
>>>  wrote:
>>>>
>>>> Hi again,
>>>>
>>>> unfortunately my problem still persists. After migrating to 1.5.1 and
>>>> putting my commit code into  onRequestHandlerExecuted() the error
>>>> messages
>>>> generated there are still not propagated to the rendered response page.
>>>>
>>>> But instead I now get the following error message:
>>>>
>>>> ERROR - DefaultExceptionMapper     - Unexpected error occurred
>>>> java.lang.IllegalStateException: Header was already written to response!
>>>>
>>>> So it seems that at this it is still to late to anything to the current
>>>> response.
>>>>
>>>> As before the error messages do get displayed after the following
>>>> request.
>>>>
>>>> At the moment I am totally stumped. Does anyone have a clue what I am
>>>> doing
>>>> wrong here?
>>>>
>>>> Thanks, Chris
>>>>
>>>>
>>>> The Sanity Resort<http://sanityresort.blogspot.com/>
>>>>
>>>> Am 24.09.2011 17:18, schrieb Igor Vaynberg:
>>>>>
>>>>> use the onRequestHandlerExecuted() to commit the transaction and
>>>>> onException() to roll it back. these are both in
>>>>> IRequestCycleListener.
>>>>>
>>>>> -igor
>>>>>
>>>>> On Mon, Sep 19, 2011 at 10:50 AM, Christian
>>>>> Huber<hu...@butterbrot.org>
>>>>>  wrote:
>>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> I just noticed that exceptions occuring in onEndRequest of a
>>>>>> RequestCycle
>>>>>> somehow do not reflect on the respone page.
>>>>>>
>>>>>> I am using an AjaxFallbackButton and the OSIV pattern and thus commit
>>>>>> my
>>>>>> database changes in onEndRequest, now if an exception occurs here I do
>>>>>> get a
>>>>>> log entry but I cannot get my application to display the corresponding
>>>>>> error
>>>>>> to the user.
>>>>>>
>>>>>> Adding a message to the feedback panel does not help as the message
>>>>>> gets
>>>>>> displayed on the following request but not the current one. I also
>>>>>> tried
>>>>>> using various AbortExceptions like RedirectToUrlException,
>>>>>> RestartResponseException or AbortWithWebErrorCodeException. This did
>>>>>> improve
>>>>>> the situation as far as the request did get aborted but there is still
>>>>>> no
>>>>>> visual display of the error.
>>>>>>
>>>>>> Setting the ResponsePage directly and/or setting redirect to true did
>>>>>> not
>>>>>> change anything.
>>>>>>
>>>>>> This sounds like a common problem and so I guess there is an easy
>>>>>> solution
>>>>>> to it, but I just don't get it right now, so any pointers are welcome.
>>>>>>
>>>>>> Thanks, Chris
>>>>>>
>>>>>> --
>>>>>> The Sanity Resort<http://sanityresort.blogspot.com/>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>

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


Re: How to handle errors in RequestCycle.onEndRequest

Posted by Christian Huber <hu...@butterbrot.org>.
Hi Igor,

I just saw you answered to my JIRA issue. I had tried your suggestion 
about throwing an exception before but to no avail (see also my comment 
on the issue):

I had tried adding

throw new RestartResponseException(ErrorPage.class);

to the onrequesthandlerexecuted() callback while ErrorPage is just an 
empty page with empty markup and mounted at "error" (calling that page 
did work when the exception was not thrown) but that caused the 
following error:

ERROR - DefaultExceptionMapper - Unexpected error occurred
org.apache.wicket.RestartResponseException
ERROR - DefaultExceptionMapper - Unexpected error occurred
java.lang.IllegalStateException: Header was already written to response!

throwing the exception directly in the homepage constuctor got me 
redirected to the error page as expected.

would you need a new quickstart for this?


The Sanity Resort <http://sanityresort.blogspot.com/>

Am 01.10.2011 17:54, schrieb Christian Huber:
> quickstart created and added to 
> https://issues.apache.org/jira/browse/WICKET-4103
>
> this quickstart does not behave exactly like my application but the 
> primary problem about messages not being displayed is reproducable. 
> please let me know if i can provide any further information and thank 
> you for your assitance.
>
>
> The Sanity Resort <http://sanityresort.blogspot.com/>
>
> Am 01.10.2011 16:47, schrieb Igor Vaynberg:
>> that sounds like a bug, please create a quickstart and attach it to 
>> jira.
>>
>> -igor
>>
>> On Sat, Oct 1, 2011 at 7:29 AM, Christian 
>> Huber<hu...@butterbrot.org>  wrote:
>>> Hi again,
>>>
>>> unfortunately my problem still persists. After migrating to 1.5.1 and
>>> putting my commit code into  onRequestHandlerExecuted() the error 
>>> messages
>>> generated there are still not propagated to the rendered response page.
>>>
>>> But instead I now get the following error message:
>>>
>>> ERROR - DefaultExceptionMapper     - Unexpected error occurred
>>> java.lang.IllegalStateException: Header was already written to 
>>> response!
>>>
>>> So it seems that at this it is still to late to anything to the current
>>> response.
>>>
>>> As before the error messages do get displayed after the following 
>>> request.
>>>
>>> At the moment I am totally stumped. Does anyone have a clue what I 
>>> am doing
>>> wrong here?
>>>
>>> Thanks, Chris
>>>
>>>
>>> The Sanity Resort<http://sanityresort.blogspot.com/>
>>>
>>> Am 24.09.2011 17:18, schrieb Igor Vaynberg:
>>>> use the onRequestHandlerExecuted() to commit the transaction and
>>>> onException() to roll it back. these are both in
>>>> IRequestCycleListener.
>>>>
>>>> -igor
>>>>
>>>> On Mon, Sep 19, 2011 at 10:50 AM, Christian 
>>>> Huber<hu...@butterbrot.org>
>>>>   wrote:
>>>>> Hi all,
>>>>>
>>>>> I just noticed that exceptions occuring in onEndRequest of a 
>>>>> RequestCycle
>>>>> somehow do not reflect on the respone page.
>>>>>
>>>>> I am using an AjaxFallbackButton and the OSIV pattern and thus 
>>>>> commit my
>>>>> database changes in onEndRequest, now if an exception occurs here 
>>>>> I do
>>>>> get a
>>>>> log entry but I cannot get my application to display the 
>>>>> corresponding
>>>>> error
>>>>> to the user.
>>>>>
>>>>> Adding a message to the feedback panel does not help as the 
>>>>> message gets
>>>>> displayed on the following request but not the current one. I also 
>>>>> tried
>>>>> using various AbortExceptions like RedirectToUrlException,
>>>>> RestartResponseException or AbortWithWebErrorCodeException. This did
>>>>> improve
>>>>> the situation as far as the request did get aborted but there is 
>>>>> still no
>>>>> visual display of the error.
>>>>>
>>>>> Setting the ResponsePage directly and/or setting redirect to true 
>>>>> did not
>>>>> change anything.
>>>>>
>>>>> This sounds like a common problem and so I guess there is an easy
>>>>> solution
>>>>> to it, but I just don't get it right now, so any pointers are 
>>>>> welcome.
>>>>>
>>>>> Thanks, Chris
>>>>>
>>>>> -- 
>>>>> The Sanity Resort<http://sanityresort.blogspot.com/>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>

Re: How to handle errors in RequestCycle.onEndRequest

Posted by Christian Huber <hu...@butterbrot.org>.
quickstart created and added to 
https://issues.apache.org/jira/browse/WICKET-4103

this quickstart does not behave exactly like my application but the 
primary problem about messages not being displayed is reproducable. 
please let me know if i can provide any further information and thank 
you for your assitance.


The Sanity Resort <http://sanityresort.blogspot.com/>

Am 01.10.2011 16:47, schrieb Igor Vaynberg:
> that sounds like a bug, please create a quickstart and attach it to jira.
>
> -igor
>
> On Sat, Oct 1, 2011 at 7:29 AM, Christian Huber<hu...@butterbrot.org>  wrote:
>> Hi again,
>>
>> unfortunately my problem still persists. After migrating to 1.5.1 and
>> putting my commit code into  onRequestHandlerExecuted() the error messages
>> generated there are still not propagated to the rendered response page.
>>
>> But instead I now get the following error message:
>>
>> ERROR - DefaultExceptionMapper     - Unexpected error occurred
>> java.lang.IllegalStateException: Header was already written to response!
>>
>> So it seems that at this it is still to late to anything to the current
>> response.
>>
>> As before the error messages do get displayed after the following request.
>>
>> At the moment I am totally stumped. Does anyone have a clue what I am doing
>> wrong here?
>>
>> Thanks, Chris
>>
>>
>> The Sanity Resort<http://sanityresort.blogspot.com/>
>>
>> Am 24.09.2011 17:18, schrieb Igor Vaynberg:
>>> use the onRequestHandlerExecuted() to commit the transaction and
>>> onException() to roll it back. these are both in
>>> IRequestCycleListener.
>>>
>>> -igor
>>>
>>> On Mon, Sep 19, 2011 at 10:50 AM, Christian Huber<hu...@butterbrot.org>
>>>   wrote:
>>>> Hi all,
>>>>
>>>> I just noticed that exceptions occuring in onEndRequest of a RequestCycle
>>>> somehow do not reflect on the respone page.
>>>>
>>>> I am using an AjaxFallbackButton and the OSIV pattern and thus commit my
>>>> database changes in onEndRequest, now if an exception occurs here I do
>>>> get a
>>>> log entry but I cannot get my application to display the corresponding
>>>> error
>>>> to the user.
>>>>
>>>> Adding a message to the feedback panel does not help as the message gets
>>>> displayed on the following request but not the current one. I also tried
>>>> using various AbortExceptions like RedirectToUrlException,
>>>> RestartResponseException or AbortWithWebErrorCodeException. This did
>>>> improve
>>>> the situation as far as the request did get aborted but there is still no
>>>> visual display of the error.
>>>>
>>>> Setting the ResponsePage directly and/or setting redirect to true did not
>>>> change anything.
>>>>
>>>> This sounds like a common problem and so I guess there is an easy
>>>> solution
>>>> to it, but I just don't get it right now, so any pointers are welcome.
>>>>
>>>> Thanks, Chris
>>>>
>>>> --
>>>> The Sanity Resort<http://sanityresort.blogspot.com/>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

Re: How to handle errors in RequestCycle.onEndRequest

Posted by Igor Vaynberg <ig...@gmail.com>.
that sounds like a bug, please create a quickstart and attach it to jira.

-igor

On Sat, Oct 1, 2011 at 7:29 AM, Christian Huber <hu...@butterbrot.org> wrote:
> Hi again,
>
> unfortunately my problem still persists. After migrating to 1.5.1 and
> putting my commit code into  onRequestHandlerExecuted() the error messages
> generated there are still not propagated to the rendered response page.
>
> But instead I now get the following error message:
>
> ERROR - DefaultExceptionMapper     - Unexpected error occurred
> java.lang.IllegalStateException: Header was already written to response!
>
> So it seems that at this it is still to late to anything to the current
> response.
>
> As before the error messages do get displayed after the following request.
>
> At the moment I am totally stumped. Does anyone have a clue what I am doing
> wrong here?
>
> Thanks, Chris
>
>
> The Sanity Resort <http://sanityresort.blogspot.com/>
>
> Am 24.09.2011 17:18, schrieb Igor Vaynberg:
>>
>> use the onRequestHandlerExecuted() to commit the transaction and
>> onException() to roll it back. these are both in
>> IRequestCycleListener.
>>
>> -igor
>>
>> On Mon, Sep 19, 2011 at 10:50 AM, Christian Huber<hu...@butterbrot.org>
>>  wrote:
>>>
>>> Hi all,
>>>
>>> I just noticed that exceptions occuring in onEndRequest of a RequestCycle
>>> somehow do not reflect on the respone page.
>>>
>>> I am using an AjaxFallbackButton and the OSIV pattern and thus commit my
>>> database changes in onEndRequest, now if an exception occurs here I do
>>> get a
>>> log entry but I cannot get my application to display the corresponding
>>> error
>>> to the user.
>>>
>>> Adding a message to the feedback panel does not help as the message gets
>>> displayed on the following request but not the current one. I also tried
>>> using various AbortExceptions like RedirectToUrlException,
>>> RestartResponseException or AbortWithWebErrorCodeException. This did
>>> improve
>>> the situation as far as the request did get aborted but there is still no
>>> visual display of the error.
>>>
>>> Setting the ResponsePage directly and/or setting redirect to true did not
>>> change anything.
>>>
>>> This sounds like a common problem and so I guess there is an easy
>>> solution
>>> to it, but I just don't get it right now, so any pointers are welcome.
>>>
>>> Thanks, Chris
>>>
>>> --
>>> The Sanity Resort<http://sanityresort.blogspot.com/>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>

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