简体   繁体   中英

org/codehaus/groovy/control/CompilationFailedException in java

I am beginner of java reporting part. I found the code on internet i creating jasper report successfully when I call in to the jFrame I got the following error:

org/codehaus/groovy/control/CompilationFailedException in java

JRDataSource dataSource = new JREmptyDataSource(1000);

Map parameters = new HashMap();
parameters.put("id", 42);

JasperPrint jasperPrint;
try {
    JasperReport report = (JasperReport) JRLoader.loadObject("C:/Users/kobinath/Documents/NetBeansProjects/payroll/src/report1.jasper");
    jasperPrint = JasperFillManager.fillReport(report, parameters, dataSource);
    JFrame frame = new JFrame("Report");
    frame.getContentPane().add(new JRViewer(jasperPrint));
    frame.pack();
    frame.setVisible(true);
} catch (JRException ex) {
    Logger.getLogger(emploee.class.getName()).log(Level.SEVERE, null, ex);
}

report1.jrxml 在此输入图像描述

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/codehaus/groovy/control/CompilationFailedException
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
    at java.lang.Class.getConstructor0(Class.java:3075)
    at java.lang.Class.getConstructor(Class.java:1825)
    at net.sf.jasperreports.engine.JasperCompileManager.getCompiler(JasperCompileManager.java:690)
    at net.sf.jasperreports.engine.JasperCompileManager.getEvaluator(JasperCompileManager.java:263)
    at net.sf.jasperreports.engine.fill.JRFillDataset.createCalculator(JRFillDataset.java:457)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:379)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:88)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:103)

Default template language isn Groovy, hence that dependency is required. You can change it by editing your jasper report template and removing the language="groovy" attribute from the jasperReport node.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM