jasper使用applet和servlet打印loadObject

时间:2011-09-29 19:00:19

标签: java applet jasper-reports

小程序为什么申请烧烤渲染器?顺便说一句,我的烧烤罐似乎没问题并且包含在同一个文件夹中。

network: Cache entry not found [url: http://localhost:8085/sg-fe/servlet/jasperprint, version: null]
network: Connecting http://localhost:8085/sg-fe/servlet/jasperprint with proxy=DIRECT
network: Connecting http://localhost:8085/ with proxy=DIRECT
network: Connecting http://localhost:8085/sg-fe/servlet/jasperprint with cookie "JSESSIONID=1B7B7C38E0625B8CB24D61A47343117F"
network: Cache entry not found [url: http://localhost:8085/sg-fe/pages/identidadeAcademicaFuncional/pedidos/net/sf/jasperreports/components/barbecue/BarbecueRenderer.class, version: null]
network: Connecting http://localhost:8085/sg-fe/pages/identidadeAcademicaFuncional/pedidos/net/sf/jasperreports/components/barbecue/BarbecueRenderer.class with proxy=DIRECT
network: Connecting http://localhost:8085/ with proxy=DIRECT
network: Connecting http://localhost:8085/sg-fe/pages/identidadeAcademicaFuncional/pedidos/net/sf/jasperreports/components/barbecue/BarbecueRenderer.class with cookie "JSESSIONID=1B7B7C38E0625B8CB24D61A47343117F"
network: Cache entry not found [url: http://localhost:8085/sg-fe/pages/identidadeAcademicaFuncional/pedidos/net/sf/jasperreports/components/barbecue/BarbecueRenderer.class, version: null]
network: Connecting http://localhost:8085/sg-fe/pages/identidadeAcademicaFuncional/pedidos/net/sf/jasperreports/components/barbecue/BarbecueRenderer.class with proxy=DIRECT
network: Connecting http://localhost:8085/sg-fe/pages/identidadeAcademicaFuncional/pedidos/net/sf/jasperreports/components/barbecue/BarbecueRenderer.class with cookie "JSESSIONID=1B7B7C38E0625B8CB24D61A47343117F"
network: Cache entry not found [url: http://localhost:8085/sg-fe/pages/identidadeAcademicaFuncional/pedidos/net/sf/jasperreports/renderers/BatikRenderer.class, version: null]
network: Connecting http://localhost:8085/sg-fe/pages/identidadeAcademicaFuncional/pedidos/net/sf/jasperreports/renderers/BatikRenderer.class with proxy=DIRECT
network: Connecting http://localhost:8085/sg-fe/pages/identidadeAcademicaFuncional/pedidos/net/sf/jasperreports/renderers/BatikRenderer.class with cookie "JSESSIONID=1B7B7C38E0625B8CB24D61A47343117F"
network: Cache entry not found [url: http://localhost:8085/sg-fe/pages/identidadeAcademicaFuncional/pedidos/net/sf/jasperreports/renderers/BatikRenderer.class, version: null]
network: Connecting http://localhost:8085/sg-fe/pages/identidadeAcademicaFuncional/pedidos/net/sf/jasperreports/renderers/BatikRenderer.class with proxy=DIRECT
network: Connecting http://localhost:8085/sg-fe/pages/identidadeAcademicaFuncional/pedidos/net/sf/jasperreports/renderers/BatikRenderer.class with cookie "JSESSIONID=1B7B7C38E0625B8CB24D61A47343117F"
net.sf.jasperreports.engine.JRException: Class not found when loading object from URL : http://localhost:8085/sg-fe/servlet/jasperprint
    at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:151)
    at LamePrintThread$1.actionPerformed(LamePrintThread.java:35)
    at java.awt.Button.processActionEvent(Button.java:409)
    at java.awt.Button.processEvent(Button.java:377)
    at java.awt.Component.dispatchEventImpl(Component.java:4629)
    at java.awt.Component.dispatchEvent(Component.java:4455)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:649)
    at java.awt.EventQueue.access$000(EventQueue.java:96)
    at java.awt.EventQueue$1.run(EventQueue.java:608)
    at java.awt.EventQueue$1.run(EventQueue.java:606)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:116)
    at java.awt.EventQueue$2.run(EventQueue.java:622)
    at java.awt.EventQueue$2.run(EventQueue.java:620)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:619)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
Caused by: java.lang.ClassNotFoundException: net.sf.jasperreports.components.barbecue.BarbecueRenderer
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:252)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:250)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:180)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:161)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:621)
    at net.sf.jasperreports.engine.util.ContextClassLoaderObjectInputStream.resolveClass(ContextClassLoaderObjectInputStream.java:75)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1592)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1513)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1749)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1346)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1963)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1887)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1770)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1346)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:368)
    at java.util.ArrayList.readObject(ArrayList.java:696)
    at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:991)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1865)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1770)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1346)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1963)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1887)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1770)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1346)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:368)
    at java.util.ArrayList.readObject(ArrayList.java:696)
    at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:991)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1865)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1770)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1346)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1963)
    at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:497)
    at net.sf.jasperreports.engine.JasperPrint.readObject(JasperPrint.java:756)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:991)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1865)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1770)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1346)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:368)
    at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:143)
    ... 23 more

是否有正确的方法来识别这类问题?

我的小程序中的一个片段:

String strUrl = "http://localhosts:8085/sg-fe/servlet/jasperprint";

            try {

                URL url = new URL(strUrl);

                JasperPrint jasperPrint = null;
                jasperPrint = (JasperPrint) JRLoader.loadObject(url);
                final JasperPrint print = jasperPrint;
                JasperPrintManager.printReport(print, true);
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (JRException e) {
                e.printStackTrace();
            }

1 个答案:

答案 0 :(得分:0)

您必须指明您的applet程序必须加载哪个jar。请参阅applet标记中的“ARCHIVE”属性。这是一个例子:

<APPLET id="printer" name="printer" CODE = "MultiplePrinting.class" CODEBASE ="/rootapp/static/applets/printer/" ARCHIVE ="plugin.jar,PrintingAyudas.jar, jasperreports-3.7.6.jar, jasperreports-applet-3.7.6.jar,commons-digester-1.7.jar,commons-logging-1.0.4.jar,commons-collections-2.1.1.jar" WIDTH = "1" HEIGHT = "1">

     <PARAM NAME = CODE VALUE = "MultiplePrinting.class" >
     <PARAM NAME = CODEBASE VALUE = "/rootapp/static/applets/printer/" >
     <PARAM NAME = ARCHIVE VALUE = "printer.jar,plugin.jar, jasperreports-3.7.6.jar,jasperreports-applet-3.7.6.jar,commons-logging-1.0.4.jar,commons-collections-2.1.1.jar,commons-digester-1.7.jar" >
     <PARAM NAME="type" VALUE="application/x-java-applet;version=1.2.2">
     <PARAM NAME="scriptable" VALUE="false">
</APPLET>

我希望它可以帮到你。