Wicket
  1. Wicket
  2. WICKET-5369

Can't set a cookie using CookieUtils during an ajax request due to java.lang.ClassCastException: org.apache.wicket.ajax.AbstractAjaxResponse$AjaxResponse cannot be cast to org.apache.wicket.request.http.WebResponse

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 6.9.1
    • Fix Version/s: 6.12.0, 7.0.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      Java 7, Servlet 2.5, Apache Tomcat 7.

      Description

      I have a subclass of org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable whose IDataProvider.iterator method indirectly calls CookieUtils.save. This causes the following stack trace:

      Caused by: java.lang.ClassCastException: org.apache.wicket.ajax.AbstractAjaxResponse$AjaxResponse cannot be cast to org.apache.wicket.request.http.WebResponse
      at org.apache.wicket.util.cookies.CookieUtils.getWebResponse(CookieUtils.java:354) ~[wicket-core-6.9.1.jar:6.9.1]
      at org.apache.wicket.util.cookies.CookieUtils.save(CookieUtils.java:297) ~[wicket-core-6.9.1.jar:6.9.1]
      at org.apache.wicket.util.cookies.CookieUtils.save(CookieUtils.java:184) ~[wicket-core-6.9.1.jar:6.9.1]

      DataTable calls its data provider's iterator method during org.apache.wicket.markup.repeater.AbstractRepeater.onBeforeRender. Apparently at this point the response isn't a WebResponse. Perhaps CookieUtils should be changed to work with a generic Response, using its getContainerResponse method.

        Activity

        Martin Grigorov made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 7.0.0 [ 12322958 ]
        Fix Version/s 6.12.0 [ 12324889 ]
        Resolution Fixed [ 1 ]
        Martin Grigorov made changes -
        Field Original Value New Value
        Assignee Martin Grigorov [ mgrigorov ]
        David Gileadi created issue -

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            David Gileadi
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development