Java中的org / codehaus / groovy / control / CompilationFailedException

时间:2019-06-07 08:21:47

标签: java

我是Java报告部分的初学者。调用jFrame时,我在Internet上成功创建了jasper报告的代码发现了以下错误:

  Java中的

org / codehaus / groovy / control / CompilationFailedException

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 enter image description here

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)

1 个答案:

答案 0 :(得分:0)

默认模板语言是Groovy,因此需要依赖项。您可以通过编辑jasper报告模板并从jasperReport节点中删除language =“ groovy”属性来对其进行更改。