Jasper report works fine in netbeans but gives an exception when deployed as a jar application

I am working on my latest project using java and jasper swing reports for reports. The reporting application works fine when I run the application in netbeans, but when I deploy it to a jar file and then try to execute it with my command, tell me, I see this huge exception text.

  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 (Unknown Source)
         at java.lang.Class.getConstructor0 (Unknown Source)
         at java.lang.Class.newInstance0 (Unknown Source)
         at java.lang.Class.newInstance (Unknown Source)
         at net.sf.jasperreports.engine.JasperCompileManager.getCompiler (JasperCompileManager.java:472)
         at net.sf.jasperreports.engine.JasperCompileManager.loadEvaluator (JasperCompileManager.java:238)
         at net.sf.jasperreports.engine.fill.JRFillDataset.createCalculator (JRFillDataset.java:421)
         at net.sf.jasperreports.engine.fill.JRBaseFiller. (JRBaseFiller.java:428)
         at net.sf.jasperreports.engine.fill.JRVerticalFiller. (JRVerticalFiller.java:76)
         at net.sf.jasperreports.engine.fill.JRVerticalFiller. (JRVerticalFiller.java:86)
         at net.sf.jasperreports.engine.fill.JRVerticalFiller. (JRVerticalFiller.java:56)
         at net.sf.jasperreports.engine.fill.JRFiller.createFiller (JRFiller.java:142)
 .
 .
 .
 .
 .... 54 more

The following function invokes a jasper report:

  public void printReport (String adID) {
        try {
             Map parameters = new HashMap ();
             InputStream jasperIS = this.getClass (). GetResourceAsStream ("/ Reports / AllHoardings.jasper");
             User connect = new User ();
             JasperPrint print = JasperFillManager.fillReport (jasperIS, parameters, connect.getConnection ());
             JasperViewer.viewReport (print, false);
         } catch (JRException je) {
             System.out.println (je.toString () + "@ line 2043");
         } catch (Exception e) {System.out.println (e.toString ());  }
     }

Image Link:

Snapshot


NetBeans Directory List

Image Link:

NetBeans Project Directory List


Inside my flask

Image Link:

Inside the flask

0
source share
1 answer
java.lang.NoClassDefFoundError: org/codehaus/groovy/control/CompilationFailedException 

This error tells me that NetBeans solves your problems with Groovy and Jasper Reports so that your JAR file is missing. Check to see if the JAR is missing in the Groovy JAR manifest. If yes, add them.

+3
source

Source: https://habr.com/ru/post/921930/


All Articles