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)
开发者_JAVA技巧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
In order to allow an applet to print you need to sign the applet:
Signing and Verifying JAR Files
Signing Your Applet
精彩评论