Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ClassCastException in DSRequest.getOperation()

    I'm am using ListGrid.removeData() to remove an item from a listgrid but am getting this exception:

    Code:
    === 2010-09-05 21:40:46,179 [0-16] INFO  RequestContext - URL: '/slims/sc/IDACall', User-Agent: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.17.8 (KHTML, like Gecko) Version/5.0.1 Safari/533.17.8': Safari with Accept-Encoding header
    === 2010-09-05 21:40:46,180 [0-14] INFO  RequestContext - URL: '/slims/sc/IDACall', User-Agent: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.17.8 (KHTML, like Gecko) Version/5.0.1 Safari/533.17.8': Safari with Accept-Encoding header
    === 2010-09-05 21:40:46,193 [0-14] DEBUG XML - Parsed XML from (in memory stream): 13ms
    === 2010-09-05 21:40:46,194 [0-16] DEBUG XML - Parsed XML from (in memory stream): 14ms
    === 2010-09-05 21:40:46,223 [0-14] DEBUG RPCManager - Processing 1 requests.
    === 2010-09-05 21:40:46,226 [0-14] DEBUG RPCManager - Request #1 (DSRequest) payload: {
        criteria:{
            attm_pk:86
        },
        operationConfig:{
            dataSource:"Attachment",
            operationType:"remove"
        },
        componentId:"isc_AGrid$SlimsListGrid_22",
        appID:"builtinApplication",
        operation:"Attachment_remove",
        oldValues:{
            attm_pk:86
        }
    }
    === 2010-09-05 21:40:46,226 [0-14] INFO  IDACall - Performing 1 operation(s)
    === 2010-09-05 21:40:46,234 [0-16] DEBUG RPCManager - Processing 1 requests.
    === 2010-09-05 21:40:46,234 [0-16] ERROR IDACall - Top-level servlet error: 
    java.lang.ClassCastException: org.apache.commons.collections.map.LinkedMap cannot be cast to java.lang.String
    	at com.isomorphic.datasource.DSRequest.getOperation(DSRequest.java:503)
    	at com.isomorphic.datasource.DSRequest.<init>(DSRequest.java:242)
    	at com.isomorphic.datasource.DSRequest.<init>(DSRequest.java:378)
    	at com.isomorphic.rpc.RPCManager.parseRequest(RPCManager.java:1464)
    Can you tell me what the problem is with the DSRequest message I am sending to the server?

    Thx

    (Using SmartGWTPower 2.3 edition)

    #2
    Do you need more info on how the DataSource is configured or how the ListGrid is defined, to analyze this problem?

    Comment


      #3
      Yes, we need more information such as what, if any, custom Java logic you have running anywhere in the processing chain.

      As a best guess, you are calling the (internal) API setOperation() with a Map.

      Comment


        #4
        There is no custom Java logic but I have found out what is triggering the error.
        It is caused by additional requestproperties we are specifying in the removeData call

        if we change this:
        Code:
        DSRequest requestProperties = new DSRequest();
        requestProperties.setWillHandleError(true);
        grid.removeData(recordToRemove, null, requestProperties);
        to this:
        Code:
        grid.removeData(recordToRemove);
        the error goes away.
        Can you try to reproduce this on your side?

        Comment


          #5
          Please use the RPC tab of the developer console to establish exactly what is being sent to the server, and let us know

          Comment


            #6
            info from the RPC tab:
            (two similar DSRequests, the first one goes OK, the second one, always fails)

            first call
            DSRequest requestProperties = new DSRequest();
            requestProperties.setWillHandleError(true);
            grid.removeData(recordToRemove1, null, requestProperties);

            Code:
            {
                "actionURL":"http://127.0.0.1:7001/slims/sc/IDACall", 
                "showPrompt":true, 
                "transport":"xmlHttpRequest", 
                "promptStyle":"dialog", 
                "bypassCache":true, 
                "data":{
                    "criteria":{
                        "attm_createdBy":"admin", 
                        "attm_file_date_created":"2010-09-08", 
                        "attm_modifiedBy":"admin", 
                        "attm_file_filesize":171584, 
                        "attm_modifiedOn":"2010-09-08T07:17:11", 
                        "attm_recordPk":0, 
                        "attm_pk":98, 
                        "attm_file_filename":"Screen shot 2010-09-07 at 16.11.17.png", 
                        "attm_file":{
                        }, 
                        "attm_createdOn":"2010-09-08T07:17:09", 
                        "rowNum":1, 
                        "select":true
                    }, 
                    "operationConfig":{
                        "dataSource":"Attachment", 
                        "repo":null, 
                        "operationType":"remove"
                    }, 
                    "componentId":"isc_AGrid$SlimsListGrid_18", 
                    "appID":"builtinApplication", 
                    "operation":"Attachment_remove", 
                    "oldValues":{
                        "attm_createdBy":"admin", 
                        "attm_file_date_created":"2010-09-08", 
                        "attm_modifiedBy":"admin", 
                        "attm_file_filesize":171584, 
                        "attm_modifiedOn":"2010-09-08T07:17:11", 
                        "attm_recordPk":0, 
                        "attm_pk":98, 
                        "attm_file_filename":"Screen shot 2010-09-07 at 16.11.17.png", 
                        "attm_file":{
                        }, 
                        "attm_createdOn":"2010-09-08T07:17:09", 
                        "rowNum":1, 
                        "select":true
                    }
                }
            }
            OK response:

            Code:
            [
                {
                    isDSResponse:true, 
                    invalidateCache:false, 
                    status:0, 
                    data:[
                        {
                            attm_pk:98
                        }
                    ]
                }
            ]
            Second call to removedata:

            DSRequest requestProperties = new DSRequest();
            requestProperties.setWillHandleError(true);
            grid.removeData(recordToRemove2, null, requestProperties);

            This leads to a DSRequest message that contains the problem (operation info as a Map)

            Code:
            {
                "actionURL":"http://127.0.0.1:7001/slims/sc/IDACall", 
                "showPrompt":true, 
                "transport":"xmlHttpRequest", 
                "promptStyle":"dialog", 
                "bypassCache":true, 
                "data":{
                    "criteria":{
                        "attm_createdBy":"admin", 
                        "attm_modifiedBy":"admin", 
                        "attm_file_date_created":"2010-09-07", 
                        "attm_modifiedOn":"2010-09-07T11:45:53", 
                        "attm_file_filesize":48157, 
                        "attm_recordPk":0, 
                        "attm_file_filename":"Screen shot 2010-09-03 at 10.34.04.png", 
                        "attm_pk":96, 
                        "attm_file":{
                        }, 
                        "attm_createdOn":"2010-09-07T11:45:51", 
                        "rowNum":0, 
                        "select":true
                    }, 
                    "operationConfig":{
                        "dataSource":"Attachment", 
                        "repo":null, 
                        "operationType":"remove"
                    }, 
                    "componentId":"isc_AGrid$SlimsListGrid_18", 
                    "appID":"builtinApplication", 
                    "operation":{
                        "ID":"Attachment_remove", 
                        "dataSource":"Attachment", 
                        "type":"remove", 
                        "filterType":"paged", 
                        "loadDataOnDemand":true, 
                        "source":"auto"
                    }, 
                    "oldValues":{
                        "attm_createdBy":"admin", 
                        "attm_modifiedBy":"admin", 
                        "attm_file_date_created":"2010-09-07", 
                        "attm_modifiedOn":"2010-09-07T11:45:53", 
                        "attm_file_filesize":48157, 
                        "attm_recordPk":0, 
                        "attm_file_filename":"Screen shot 2010-09-03 at 10.34.04.png", 
                        "attm_pk":96, 
                        "attm_file":{
                        }, 
                        "attm_createdOn":"2010-09-07T11:45:51", 
                        "rowNum":0, 
                        "select":true
                    }
                }
            }
            Error response:

            Code:
            com.isomorphic.servlet.IDACall top-level exception<BR>
            
            java.lang.ClassCastException: org.apache.commons.collections.map.LinkedMap cannot be cast to java.lang.String
            	at com.isomorphic.datasource.DSRequest.getOperation(DSRequest.java:503)
            	at com.isomorphic.datasource.DSRequest.<init>(DSRequest.java:242)
            	at com.isomorphic.datasource.DSRequest.<init>(DSRequest.java:378)
            	at com.isomorphic.rpc.RPCManager.parseRequest(RPCManager.java:1464)
            	at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:267)
            	at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:252)
            	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:90)
            	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:54)
            	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
            	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
            	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
            	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
            	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
            	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
            	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
            	at org.jasig.cas.client.util.HttpServletRequestWrapperFilter.doFilter(HttpServletRequestWrapperFilter.java:50)
            	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
            	at org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:167)
            	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
            	at org.jasig.cas.client.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:94)
            	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
            	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
            	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
            	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
            	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
            	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
            	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
            	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
            	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
            	at org.mortbay.jetty.Server.handle(Server.java:324)
            	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
            	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
            	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
            	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
            	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
            	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
            	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
            </PRE>

            Comment


              #7
              Did I provide enough information to reproduce this issue?

              Comment


                #8
                We tried adding equivalent code to the recordClickHandler in the builtInDS sample:

                Code:
                                    DSRequest requestProperties = new DSRequest();
                                    requestProperties.setWillHandleError(true);
                                    boundList.removeData(boundList.getSelectedRecord(), null, requestProperties);
                It's not clear how, but something in your code is munging the dsRequest before it leaves the browser, and it doesn't appear to be just due to passing requestProperties. It might be an implementation of transformRequest, or requestProperties set at the DataSource level.

                Comment


                  #9
                  You can also try getJSObj() on the DSRequest and dumping it via SC.echo() - you should see that there's no extra data in there (eg an "operation" attribute with a Map as the value). We do not see such extra data.

                  Comment


                    #10
                    I finally was able to find out what is causing this problem: it's the reuse of the requestProperties DSRequest object.

                    You can reproduce this in the showcase example GridDataBoundRemoveSample
                    If you change it as illustrated below and you select two records in the grid and try to remove them, you will see the error.

                    Code:
                    final DSRequest requestProperties = new DSRequest();
                    removeAll.addClickHandler(new ClickHandler() {  
                                public void onClick(ClickEvent event) {  
                                    ListGridRecord[] selectedRecords = countryGrid.getSelection();  
                                    for(ListGridRecord rec: selectedRecords) {  
                                        countryGrid.removeData(rec, null, requestProperties);  
                                    }  
                                }             
                            });
                    To me, this seems like unexpected behavior, you would not expect that the requestProperties object you pass on, is changed after the execution of the request.

                    Comment


                      #11
                      Since it was easy, we've gone ahead and avoided any side-effects for this particular API. However, please assume that in general a "DSRequest Properties" argument like this is assumed to be one-shot usage, and may be modified.

                      Comment

                      Working...
                      X