java.lang.ClassCastException

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

java.lang.ClassCastException

akervcc
This post was updated on .
here is the error msg

嚴重的: Servlet.service() for servlet jsp threw exception
java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.util.List
        at com.github.dandelion.datatables.jsp.tag.TableTag.doEndTag(TableTag.java:248)
        at org.apache.jsp.AccountRegLog2_jsp._jspx_meth_datatables_005ftable_005f0(AccountRegLog2_jsp.java:405)
        at org.apache.jsp.AccountRegLog2_jsp._jspService(AccountRegLog2_jsp.java:222)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
        at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:164)

JSp code here (AccountRegLog2.jsp):

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>  
<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %>
<datatables:table id="iservicelist" data="${iservicelist }" cssClass="display">
<datatables:column title="Id" property="mobileno" />
</datatables:table>

This is controller:

        public String execute() throws Exception{
               
                iservicelist = accountRegLogService.findiServiceAll();
               
                return SUCCESS;
        }

s2 config:

            <action name="AccountRegLog2" class="accountRegLogAction" method="execute">
                        <result name="success">/AccountRegLog2.jsp</result>
            </action>

pom:
              <dependency>
                 <groupId>com.github.dandelion</groupId>
                 <artifactId>datatables-jsp</artifactId>
                   <version>1.1.0</version>
              </dependency>
              <dependency>
                 <groupId>com.github.dandelion</groupId>
                 <artifactId>datatables-struts2</artifactId>
                   <version>1.1.0</version>
              </dependency>
                        <dependency>
                          <groupId>com.github.dandelion</groupId>
                          <artifactId>datatables-spring3</artifactId>
                          <version>1.1.0</version>
                        </dependency>

web.xml:

   
           <servlet>
              <servlet-name>dandelionServlet</servlet-name>
              <servlet-class>com.github.dandelion.core.web.DandelionServlet</servlet-class>
              <load-on-startup>2</load-on-startup>
           </servlet>
           <servlet-mapping>
              <servlet-name>dandelionServlet</servlet-name>
              <url-pattern>/dandelion-assets/*</url-pattern>
           </servlet-mapping>
       
       
           
           <filter>
              <filter-name>datatablesFilter</filter-name>
              <filter-class>com.github.dandelion.datatables.core.web.filter.DatatablesFilter</filter-class>
           </filter>
           <filter-mapping>
              <filter-name>datatablesFilter</filter-name>
              <url-pattern>/*</url-pattern>
           </filter-mapping>
       
           
           <filter>
              <filter-name>dandelionFilter</filter-name>
              <filter-class>com.github.dandelion.core.web.DandelionFilter</filter-class>
           </filter>
           <filter-mapping>
              <filter-name>dandelionFilter</filter-name>
              <url-pattern>/*</url-pattern>
           </filter-mapping>


This is first time to use Dandelion-Datatables
What`s wrong with my code
i really have no idea to fix this issue

=> the version of Dandelion-Datatables  1.1.0
=> the template engine you're using      JSP
=> the app server   Tomcat7 Servlet 3.0
=> the web browser you're using  Chrome
=> whether you are using Spring/Spring MVC  (Spring Struts2)
Reply | Threaded
Open this post in threaded view
|

Re: java.lang.ClassCastException

MrLobato
Hi!
We are migrating our application from version(0.9.2) to the newest dandelion datatables version(1.1.0) and we are facing the same problem while calling to the datatables.

The configuration set on our pom.xml is:

  <dependency>
                    <groupId>com.github.dandelion</groupId>
                    <artifactId>datatables-jsp</artifactId>
                    <version>1.1.0</version>
                </dependency>
                <dependency>
                   <groupId>com.github.dandelion</groupId>
                   <artifactId>datatables-struts2</artifactId>
                   <version>1.1.0</version>
                </dependency>

The datatable definition on the jsp is as follows. We are getting vehicles data from an Ajax Action.

 
<datatables:table id="vehicleTable" url="VehicleAjaxList.action"  row="vehicle" serverSide="true" processing="true">
   <datatables:column titleKey="web.vehicleList.tableHeader.producer" property="producer" filterable="true" sortInitDirection="desc"/>
 </datatables:table>

This table was working fine with 0.9.2 and with the new version 1.1.0 we are getting the following error:

Sep 14, 2015 5:08:09 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.util.List
        at com.github.dandelion.datatables.jsp.tag.TableTag.doEndTag(TableTag.java:248)
        at org.apache.jsp.jsp.list.lockerList_jsp._jspx_meth_datatables_005ftable_005f0(lockerList_jsp.java:735)
        at org.apache.jsp.jsp.list.lockerList_jsp._jspx_meth_s_005fform_005f0(lockerList_jsp.java:544)
        at org.apache.jsp.jsp.list.lockerList_jsp._jspService(lockerList_jsp.java:220)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:604)
        at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:543)
        at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:954)
        at org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:688)
        at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:682)
        at org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:80)
        at org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesRequestContext.java:73)
        at org.apache.tiles.context.TilesRequestContextWrapper.dispatch(TilesRequestContextWrapper.java:72)
        at org.apache.struts2.tiles.StrutsTilesRequestContext.dispatch(StrutsTilesRequestContext.java:88)
        at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:283)
        at org.apache.tiles.jsp.taglib.InsertAttributeTag.render(InsertAttributeTag.java:140)
        at org.apache.tiles.jsp.taglib.InsertAttributeTag.render(InsertAttributeTag.java:117)
        at org.apache.tiles.jsp.taglib.RenderTagSupport.execute(RenderTagSupport.java:154)
        at org.apache.tiles.jsp.taglib.RoleSecurityTagSupport.doEndTag(RoleSecurityTagSupport.java:75)
        at org.apache.tiles.jsp.taglib.ContainerTagSupport.doEndTag(ContainerTagSupport.java:80)
        at org.apache.jsp.jsp.layout.baseLayout_jsp._jspx_meth_tiles_005finsertAttribute_005f3(baseLayout_jsp.java:444)
        at org.apache.jsp.jsp.layout.baseLayout_jsp._jspService(baseLayout_jsp.java:147)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
        at org.apache.tiles.servlet.context.ServletTilesRequestContext.forward(ServletTilesRequestContext.java:198)
        at org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch(ServletTilesRequestContext.java:179)
        at org.apache.tiles.context.TilesRequestContextWrapper.dispatch(TilesRequestContextWrapper.java:72)
        at org.apache.struts2.tiles.StrutsTilesRequestContext.dispatch(StrutsTilesRequestContext.java:88)
        at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:606)
        at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:246)
        at org.apache.struts2.views.tiles.TilesResult.doExecute(TilesResult.java:105)
        at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
        at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:374)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:278)
        at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
        at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)
        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)
        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:90)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:192)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at xx.xx.xx.web.interceptors.SingleSignOnInterceptor.intercept(SingleSignOnInterceptor.java:65)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
        at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
        at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:511)
        at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
        at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
        at xx.xx.xx.web.dispatcher.GIDFilterDispatcher.doFilter(GIDFilterDispatcher.java:80)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Unknown Source)


We have checked the code and found that in the new version there is a new code that could be causing the problem:

      // The table must be generated and displayed
      else {

         if (request.getAttribute(DatatableComponent.DDL_DT_REQUESTATTR_TABLES) == null) {
            List<HtmlTable> htmlTables = new ArrayList<HtmlTable>();
            htmlTables.add(table);
            request.setAttribute(DatatableComponent.DDL_DT_REQUESTATTR_TABLES, htmlTables);
         }
         else {
            List<HtmlTable> htmlTables = (List<HtmlTable>) request
                  .getAttribute(DatatableComponent.DDL_DT_REQUESTATTR_TABLES);
            htmlTables.add(table);
         }


Our current configuration is:
=> the version of Dandelion-Datatables  1.1.0
=> the template engine you're using      JSP
=> the app server   Tomcat7 Servlet 3.0
=> the web browser you're using  Chrome(45.0.2454.85) or Firefox(40.0.3)
=> whether you are using Spring/Spring MVC  (Spring Struts2)