从 Applet 打印 JasperReport

发布于 2024-10-19 08:03:04 字数 1933 浏览 1 评论 0原文

我开发了使用 JasperReports 进行报告的 Web 应用程序。 因为我必须使用小程序在客户端查看报告。我可以正常在小程序中看到报告,但是当涉及到打印时(当我单击查看器中的“打印”按钮时),它会抛出一个异常,我可以在 Java 控制台中看到该异常。我浏览了很多关于这个问题的资料,并按照网上专家的建议做了任何事情。我在 catalina.policy 文件中添加了授予权限,因为我使用 Tomcat 作为我的 Web 服务器。另外,在 java.policy 文件中添加了对我的小程序的授予权限作为代码库。我签署了包含 Applet 类文件的 jar 文件。但我仍然遇到同样的错误。

下面是 Java 控制台的堆栈跟踪。

Java Plug-in 1.6.0_24
Using JRE version 1.6.0_24-b07 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Administrator


Exception in thread "Thread-13" java.lang.ExceptionInInitializerError
    at net.sf.jasperreports.view.JRViewer$21.run(JRViewer.java:1211)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.print)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPackageAccess(Unknown Source)
    at sun.plugin2.applet.Applet2SecurityManager.checkPackageAccess(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at net.sf.jasperreports.engine.JasperPrintManager.<clinit>(JasperPrintManager.java:419)
    ... 2 more

I have developed web application which uses JasperReports for reporting purpose.
In that I have to use Applet to View report at Client side. I can see report in applet normally , but when it comes to printing (when i clicked on Print Button in Viewer), it throws an Exception which I can see in Java Console. I surfed lots of about this Problem and did whatever which are suggested by experts on the net. I added the grant permission in catalina.policy file as I uses the Tomcat as my web server. Also, added grant permission to my applet as a codebase in java.policy file. I signed the jar file which has class file for an Applet. But I still getting the same error.

below is the stack trace from Java console .

Java Plug-in 1.6.0_24
Using JRE version 1.6.0_24-b07 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Administrator


Exception in thread "Thread-13" java.lang.ExceptionInInitializerError
    at net.sf.jasperreports.view.JRViewer$21.run(JRViewer.java:1211)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.print)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPackageAccess(Unknown Source)
    at sun.plugin2.applet.Applet2SecurityManager.checkPackageAccess(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at net.sf.jasperreports.engine.JasperPrintManager.<clinit>(JasperPrintManager.java:419)
    ... 2 more

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

江心雾 2024-10-26 08:03:04

为了允许小程序打印,您需要对该小程序进行签名:

签名并验证 JAR 文件

签署您的 Applet

In order to allow an applet to print you need to sign the applet:

Signing and Verifying JAR Files

Signing Your Applet

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文