1

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 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)
Fábio Nascimento
  • 2,644
  • 1
  • 21
  • 27
creative one2018
  • 131
  • 2
  • 11

1 Answers1

1

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.

TechFree
  • 2,600
  • 1
  • 17
  • 18
  • i removed language="groovy" attribute but again show the error of java.lang.NoClassDefFoundError: org/codehaus/groovy/control/CompilationFailedException at java.lang.Class.getDeclaredConstructors0(Native Method) – creative one2018 Jun 07 '19 at 08:44
  • If you are using JasperStudio/iReport , configure the language to be Java. Also in jrxml, update language="Java" – TechFree Jun 07 '19 at 09:03
  • java.lang.NoClassDefFoundError: org/codehaus/groovy/control/CompilationFailedException at java.lang.Class.getDeclaredConstructors0(Native Method) – creative one2018 Jun 07 '19 at 09:16