Jasper报告在netbeans中运行良好,但在部署为jar应用程序时会出现异常

时间:2010-11-20 14:57:14

标签: java swing jasper-reports ireport

我正在使用java swings和jasper报告进行最后一年的项目报告。当我在netbeans中运行应用程序但是当我将它部署到jar文件然后尝试执行它时,包括报告的应用程序工作正常使用我的命令提示符,我看到了这个异常的大文本。

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

以下函数调用jasper报告:

    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());       }
    }

http://i296.photobucket.com/albums/mm176/charanraj1191g/jasper.png

链接到图片:

The Snap Shot


netbeans

中的目录列表

http://i296.photobucket.com/albums/mm176/charanraj1191g/dir_list.png

链接到图片:

Project directory listing in netbeans


在我的jar文件中

http://i296.photobucket.com/albums/mm176/charanraj1191g/jar.png

链接到图片:

Inside the jar file

1 个答案:

答案 0 :(得分:3)

java.lang.NoClassDefFoundError: org/codehaus/groovy/control/CompilationFailedException

这个错误告诉我,NetBeans正在以一种你的JAR文件没有的方式解决Groovy和Jasper Reports的问题。检查JAR清单中是否缺少与Groovy相关的JAR。如果是,请添加它们。