java.lang.ClassCastException: YOUR_REPORT_NAME_1180710532958_496838 cannot be cast to net.sf.jasperreports.engine.fill.JREvaluator

Spring JIRA | Kees van Dieren | 10 years ago
  1. 0

    Jasper report generated classes, are not loaded correct by this Class loader. Create a bean which compiles a jasper report, and fills a jasper report. The fill step from the Jasper report will work with the normal class loader. If called from a main() / web container, this report works normally. If called from a JUnit tests that extends from AbstractJpaTests, it will not work. The following error will occur: java.lang.ClassCastException: YOUR_REPORT_NAME_1180710532958_496838 cannot be cast to net.sf.jasperreports.engine.fill.JREvaluator at net.sf.jasperreports.engine.design.JRAbstractJavaCompiler.loadEvaluator(JRAbstractJavaCompiler.java:83) I have seen the generated class, and it does extend net.sf.jasperreports.engine.fill.JREvaluator so it should bew possible to cast it to this type. the JrClassLoader from Jasper reports, has the OrmXmlOverridingShadowingClassLoader as parent class loader. The class Classloader, method protected final Class<?> defineClass(String name, byte[] b, int off, int len, ProtectionDomain protectionDomain) is called, and gives a wrong class as result Jasper reports code: // compile report String myReportXml = "<?xml version=\"1.0\"?> " + "<!DOCTYPE jasperReport " + "PUBLIC \"-//JasperReports//DTD Report Design//EN\" "+ "\"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd\"> " + "<jasperReport name=\"Simple_Report\"> " + "<detail>" + "<band height=\"20\">" + "<staticText>" + "<reportElement x=\"180\" y=\"0\" width=\"200\" height=\"20\"/>" + "<text><![CDATA[Hello World!]]></text>" + "</staticText>" + "</band>" + "</detail>" + "</jasperReport>"; // Using depricated StringBufferInputStream // No method accepting a StringReader is available JasperReport myJasperReport = JasperCompileManager.compileReport( new StringBufferInputStream(myReportXml ); // fill report, this steps failed if OrmXmlOverridingShadowingClassLoader is used! JasperPrint myJasperPrint = JasperFillManager.fillReport( myJasperReport, new HashMap(), new JREmptyDataSource()); Workaround: do not test Jasper reports in AbstractJpaTests, but use other JUnit superclasses instead.

    Spring JIRA | 10 years ago | Kees van Dieren
    java.lang.ClassCastException: YOUR_REPORT_NAME_1180710532958_496838 cannot be cast to net.sf.jasperreports.engine.fill.JREvaluator
  2. 0

    Jasper report generated classes, are not loaded correct by this Class loader. Create a bean which compiles a jasper report, and fills a jasper report. The fill step from the Jasper report will work with the normal class loader. If called from a main() / web container, this report works normally. If called from a JUnit tests that extends from AbstractJpaTests, it will not work. The following error will occur: java.lang.ClassCastException: YOUR_REPORT_NAME_1180710532958_496838 cannot be cast to net.sf.jasperreports.engine.fill.JREvaluator at net.sf.jasperreports.engine.design.JRAbstractJavaCompiler.loadEvaluator(JRAbstractJavaCompiler.java:83) I have seen the generated class, and it does extend net.sf.jasperreports.engine.fill.JREvaluator so it should bew possible to cast it to this type. the JrClassLoader from Jasper reports, has the OrmXmlOverridingShadowingClassLoader as parent class loader. The class Classloader, method protected final Class<?> defineClass(String name, byte[] b, int off, int len, ProtectionDomain protectionDomain) is called, and gives a wrong class as result Jasper reports code: // compile report String myReportXml = "<?xml version=\"1.0\"?> " + "<!DOCTYPE jasperReport " + "PUBLIC \"-//JasperReports//DTD Report Design//EN\" "+ "\"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd\"> " + "<jasperReport name=\"Simple_Report\"> " + "<detail>" + "<band height=\"20\">" + "<staticText>" + "<reportElement x=\"180\" y=\"0\" width=\"200\" height=\"20\"/>" + "<text><![CDATA[Hello World!]]></text>" + "</staticText>" + "</band>" + "</detail>" + "</jasperReport>"; // Using depricated StringBufferInputStream // No method accepting a StringReader is available JasperReport myJasperReport = JasperCompileManager.compileReport( new StringBufferInputStream(myReportXml ); // fill report, this steps failed if OrmXmlOverridingShadowingClassLoader is used! JasperPrint myJasperPrint = JasperFillManager.fillReport( myJasperReport, new HashMap(), new JREmptyDataSource()); Workaround: do not test Jasper reports in AbstractJpaTests, but use other JUnit superclasses instead.

    Spring JIRA | 10 years ago | Kees van Dieren
    java.lang.ClassCastException: YOUR_REPORT_NAME_1180710532958_496838 cannot be cast to net.sf.jasperreports.engine.fill.JREvaluator
  3. 0

    Jasperreports VS Weblogic

    Oracle Community | 6 years ago | 865328
    net.sf.jasperreports.engine.JRException: Error loading expression class : RequestProposal_1306320181067_81576
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Memcached Java客户端2.6.1发布 - 编程语言 - ITeye资讯

    iteye.com | 1 year ago
    java.lang.ClassCastException: cannot be cast to
  6. 0

    cannot be cast to javax.servlet.Filter | Oracle Community

    oracle.com | 8 months ago
    java.lang.ClassCastException: cannot be cast to javax.servlet.Filter

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.ClassCastException

      YOUR_REPORT_NAME_1180710532958_496838 cannot be cast to net.sf.jasperreports.engine.fill.JREvaluator

      at net.sf.jasperreports.engine.design.JRAbstractJavaCompiler.loadEvaluator()
    2. JasperReports
      JRAbstractJavaCompiler.loadEvaluator
      1. net.sf.jasperreports.engine.design.JRAbstractJavaCompiler.loadEvaluator(JRAbstractJavaCompiler.java:83)
      1 frame