JasperReports错误|尝试从Windows下的System32文件夹加载文件

时间:2013-06-03 04:16:12

标签: java swing jasper-reports dynamic-reports

使用 DynamicReports (依次构建Jasper报告)创建Swing应用程序以打印(显示和保存)pdf文件。

应用程序在 Swing 应用程序的 Eclipse 调用中顺利运行,但在作为可执行jar运行时无法提供FileNotFoundException(Access is denied)

以下堆栈跟踪:

    C:\WINDOWS\system32\Report_1370232068590_862159.java
    at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toJasperReport(JasperReportBuilder.java:278) ~[jar:rsrc:dynamicreports-core-3.1.3.jar!/:na]
    at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toJasperPrint(JasperReportBuilder.java:308) ~[jar:rsrc:dynamicreports-core-3.1.3.jar!/:na]
    at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.export(JasperReportBuilder.java:596) ~[jar:rsrc:dynamicreports-core-3.1.3.jar!/:na]
    at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toPdf(JasperReportBuilder.java:516) ~[jar:rsrc:dynamicreports-core-3.1.3.jar!/:na]
    at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toPdf(JasperReportBuilder.java:512) ~[jar:rsrc:dynamicreports-core-3.1.3.jar!/:na]
    at test.firewall.desktop.FirewallAccessTask.makeFirewallPIEChart(FirewallAccessTask.java:130) [rsrc:./:na]
    at test.firewall.desktop.FirewallAccessTask.doInBackground(FirewallAccessTask.java:86) [rsrc:./:na]
    at test.firewall.desktop.FirewallAccessTask.doInBackground(FirewallAccessTask.java:1) [rsrc:./:na]
    at javax.swing.SwingWorker$1.call(Unknown Source) [na:1.7.0_21]
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) [na:1.7.0_21]
    at java.util.concurrent.FutureTask.run(Unknown Source) [na:1.7.0_21]
    at javax.swing.SwingWorker.run(Unknown Source) [na:1.7.0_21]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.7.0_21]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.7.0_21]
    at java.lang.Thread.run(Unknown Source) [na:1.7.0_21]
Caused by: net.sf.jasperreports.engine.JRException: Error saving expressions class file : C:\WINDOWS\system32\Report_1370232068590_862159.java
    at net.sf.jasperreports.engine.util.JRSaver.saveClassSource(JRSaver.java:153) ~[jar:rsrc:jasperreports-5.0.4.jar!/:na]
    at net.sf.jasperreports.engine.design.JRAbstractCompiler.getSourceFile(JRAbstractCompiler.java:310) ~[jar:rsrc:jasperreports-5.0.4.jar!/:na]
    at net.sf.jasperreports.engine.design.JRAbstractCompiler.createCompileUnit(JRAbstractCompiler.java:282) ~[jar:rsrc:jasperreports-5.0.4.jar!/:na]
    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:177) ~[jar:rsrc:jasperreports-5.0.4.jar!/:na]
    at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:240) ~[jar:rsrc:jasperreports-5.0.4.jar!/:na]
    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:490) ~[jar:rsrc:jasperreports-5.0.4.jar!/:na]
    at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toJasperReport(JasperReportBuilder.java:275) ~[jar:rsrc:dynamicreports-core-3.1.3.jar!/:na]
    ... 14 common frames omitted
Caused by: java.io.FileNotFoundException: C:\WINDOWS\system32\Report_1370232068590_862159.java (Access is denied)
    at java.io.FileOutputStream.open(Native Method) ~[na:1.7.0_21]
    at java.io.FileOutputStream.<init>(Unknown Source) ~[na:1.7.0_21]
    at java.io.FileOutputStream.<init>(Unknown Source) ~[na:1.7.0_21]
    at java.io.FileWriter.<init>(Unknown Source) ~[na:1.7.0_21]
    at net.sf.jasperreports.engine.util.JRSaver.saveClassSource(JRSaver.java:145) ~[jar:rsrc:jasperreports-5.0.4.jar!/:na]
    ... 20 common frames omitted

1 个答案:

答案 0 :(得分:1)

在此处输入代码,就像

中的文件一样

C:\WINDOWS\system32\Report_1370232068590_862159.java无权阅读。

给予许可:

  

右键单击文件 - &gt;转到属性 - &gt;安全 - &gt;编辑 - &gt;   授予您的用户完全控制权限

我认为,这可能会解决您的问题。