Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4794

Subreport call "Caused by: java.lang.ClassCastException: org.apache.struts2.views.jasperreports.ValueStackDataSource cannot be cast to java.util.Collection"

    Details

    • Flags:
      Important

      Description

      I get the following error if I call in my jasper report “A” a subreport “B”.

      Caused by: java.lang.ClassCastException: org.apache.struts2.views.jasperreports.ValueStackDataSource cannot be cast to java.util.Collection
      

      This errors occurs upwards struts2 version 2.3.16. Same code will be executed without errors until struts2 core 2.3.15.3 and struts 2 Jasper Reports Plugin version 2.3.15.3.

      My defined variable $F{maintenanceBookletItemDAOList} is a java.util.collection.

      This bug occurs after the struts2 version 2.3.15.3 (Oct 2013) although it will be stated that the error has been fixed WW-3698

      I have tested all other and latest version of struts2 core and struts2 jasper reports plugin version without success if I call in my report A a subreport B via new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{maintenanceBookletItemDAOList}) and
      <result name="success" type="jasper">

      <action name="printAllMaintenanceBookletEntries" class="..myhiddenpackage..MaintenanceBookletAction" method="printAllMaintenanceBookletEntries">
      		<result name="success" type="jasper" >
      			<param name="location">/jasper/MaintenanceBookletEntries.jasper</param>
      			<param name="dataSource">allMaintenanceBookletPrintDAOList</param>
      			<param name="format">PDF</param>
      		</result>
      		<result name="error">
      			/jsp/modernLayout/maintenanceBooklet/maintenanceEntries.jsp
      		</result>
      	</action> 
      
      net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : 
      	Source text : new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F\{maintenanceBookletItemDAOList})
      	at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:203)
      	at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591)
      	at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559)
      	at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:876)
      	at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:356)
      	at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:275)
      	at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:257)
      	at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:473)
      	at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2021)
      	at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:755)
      	at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:265)
      	at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)
      	at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:836)
      	at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:765)
      	at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:84)
      	at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624)
      	at org.apache.struts2.views.jasperreports.JasperReportsResult.doExecute(JasperReportsResult.java:325)
      	at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
      	at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:371)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275)
      	at org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
      	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	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:246)
      	at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)
      	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)
      	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	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:246)
      	at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
      	at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
      	at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)
      	at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
      	at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      	at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:178)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
      	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
      	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
      	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
      	at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.ClassCastException: org.apache.struts2.views.jasperreports.ValueStackDataSource cannot be cast to java.util.Collection
      	at MaintenanceBookletEntry_1493377131470_196207.evaluate(MaintenanceBookletEntry_1493377131470_196207:517)
      	at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:190)
      	... 87 more
      

        Issue Links

          Activity

          Hide
          lukaszlenart Lukasz Lenart added a comment -

          Have you tried to set wrapField flag to false/true? This flag was introduced in WW-3698 to allow handle two different use cases.

          Show
          lukaszlenart Lukasz Lenart added a comment - Have you tried to set wrapField flag to false/true ? This flag was introduced in WW-3698 to allow handle two different use cases.
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user yasserzamani opened a pull request:

          https://github.com/apache/struts/pull/143

          WW-4794 Fixes wrapField's where clause

          Removes wrong `!` from `wrapField`'s where clause.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/yasserzamani/struts WW-4794

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/struts/pull/143.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #143


          commit fa20b71fc2b7764e9f5bb1ed14fb356ab6fb3258
          Author: Yasser Zamani <yasser.zamani@live.com>
          Date: 2017-06-20T12:12:08Z

          WW-4794 Fixes wrapField's where clause


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user yasserzamani opened a pull request: https://github.com/apache/struts/pull/143 WW-4794 Fixes wrapField's where clause Removes wrong `!` from `wrapField`'s where clause. You can merge this pull request into a Git repository by running: $ git pull https://github.com/yasserzamani/struts WW-4794 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/struts/pull/143.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #143 commit fa20b71fc2b7764e9f5bb1ed14fb356ab6fb3258 Author: Yasser Zamani <yasser.zamani@live.com> Date: 2017-06-20T12:12:08Z WW-4794 Fixes wrapField's where clause
          Hide
          yasser.zamani Yasser Zamani added a comment -

          Deniz Renkligül, after next release of S2 which includes above changes, please try:

          <action name="printAllMaintenanceBookletEntries" class="..myhiddenpackage..MaintenanceBookletAction" method="printAllMaintenanceBookletEntries">
          		<result name="success" type="jasper" >
          			<param name="location">/jasper/MaintenanceBookletEntries.jasper</param>
          			<param name="dataSource">allMaintenanceBookletPrintDAOList</param>
          			<param name="format">PDF</param>
          <param name="wrapField">false</param>
          		</result>
          		<result name="error">
          			/jsp/modernLayout/maintenanceBooklet/maintenanceEntries.jsp
          		</result>
          	</action> 
          

          I reproduced your problem and above PR changes fixes issue here

          Show
          yasser.zamani Yasser Zamani added a comment - Deniz Renkligül , after next release of S2 which includes above changes, please try: <action name= "printAllMaintenanceBookletEntries" class= "..myhiddenpackage..MaintenanceBookletAction" method= "printAllMaintenanceBookletEntries" > <result name= "success" type= "jasper" > <param name= "location" > /jasper/MaintenanceBookletEntries.jasper </param> <param name= "dataSource" > allMaintenanceBookletPrintDAOList </param> <param name= "format" > PDF </param> <param name= "wrapField" > false </param> </result> <result name= "error" > /jsp/modernLayout/maintenanceBooklet/maintenanceEntries.jsp </result> </action> I reproduced your problem and above PR changes fixes issue here
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit fa20b71fc2b7764e9f5bb1ed14fb356ab6fb3258 in struts's branch refs/heads/master from Yasser Zamani
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=fa20b71 ]

          WW-4794 Fixes wrapField's where clause

          Show
          jira-bot ASF subversion and git services added a comment - Commit fa20b71fc2b7764e9f5bb1ed14fb356ab6fb3258 in struts's branch refs/heads/master from Yasser Zamani [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=fa20b71 ] WW-4794 Fixes wrapField's where clause
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/struts/pull/143

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/struts/pull/143
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          PR got merged, thanks Yasser Zamani!

          Show
          lukaszlenart Lukasz Lenart added a comment - PR got merged, thanks Yasser Zamani !
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build Struts-JDK7-master #640 (See https://builds.apache.org/job/Struts-JDK7-master/640/)
          WW-4794 Fixes wrapField's where clause (yasser.zamani: rev fa20b71fc2b7764e9f5bb1ed14fb356ab6fb3258)

          • (edit) plugins/jasperreports/src/main/java/org/apache/struts2/views/jasperreports/ValueStackDataSource.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build Struts-JDK7-master #640 (See https://builds.apache.org/job/Struts-JDK7-master/640/ ) WW-4794 Fixes wrapField's where clause (yasser.zamani: rev fa20b71fc2b7764e9f5bb1ed14fb356ab6fb3258) (edit) plugins/jasperreports/src/main/java/org/apache/struts2/views/jasperreports/ValueStackDataSource.java
          Hide
          yasser.zamani Yasser Zamani added a comment - - edited

          My pleasure, you're welcome Lukasz Lenart

          Show
          yasser.zamani Yasser Zamani added a comment - - edited My pleasure, you're welcome Lukasz Lenart

            People

            • Assignee:
              Unassigned
              Reporter:
              DenizR Deniz Renkligül
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development