| Author |
Problem with jasper report -loading stream
|
christina ku
Greenhorn
Joined: Jan 06, 2005
Posts: 8
|
|
Hi there... i am currently experimentating with ireport and jasper report... i have the following code: public void display() { FileInputStream file = new FileInputStream("D:\\reports_jasper\\JASPER\\report1.jasper"); System.out.println("loading report.. file read "+file.available()); JasperReport jasperReport = (JasperReport) JRLoader.loadObject(file); System.out.println("Successfully created jasper report"); java.sql.Connection con=null; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); con = DriverManager.getConnection("jdbc:mysql://localhost/eply", "user", "123"); if(!con.isClosed()) System.out.println("Successfully connected to MySQL server using TCP/IP..."); } catch(Exception e) { System.out.println("Exception: "+ e); } JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,null,con); JasperViewer.viewReport(jasperPrint,false); } catch(Exception e) { System.out.println("There is exception here"+ e); } } When i run my code, it gives me an error like below: loading report.. file read 14143 There is exception herenet.sf.jasperreports.engine.JRException: Error loading object from InputStream It will never print successfully created jasper report.. so i guess it has to do with my loading of the jasper report file. i use ireport to create my report and it compile the report1.jrxml into report1.jasper. i dun understand the error. i included the jasperreports-0.6.2.jar into my library which i run under eclipse. is there any other things that i miss out? chris
|
 |
Alexandru Popescu
Ranch Hand
Joined: Jul 12, 2004
Posts: 995
|
|
christina, you'll probably find out more about your problem if you'll print out the whole exception stacktrace. if this will not give you a better idea, try pasting it here and somebody might find out the issue. good luck -- ./pope
|
blog - InfoQ.com
|
 |
christina ku
Greenhorn
Joined: Jan 06, 2005
Posts: 8
|
|
Aee.. well... that's it all that it prints out from my code inside the catch statement. Doesn't help much does it? How come i could not load the .jasper file? i search the net and almost all people got along well with the same code i have. any advice? or suggestion? chris
|
 |
Alexandru Popescu
Ranch Hand
Joined: Jul 12, 2004
Posts: 995
|
|
christina I am pretty sure that some e.printStackTrace(); in catch blocks will reveal you more details ;-). -- ./pope
|
 |
christina ku
Greenhorn
Joined: Jan 06, 2005
Posts: 8
|
|
okie.. i paste that in the catch clause for JRException and this is wat it gives me. Brace yourself.. : java.io.InvalidClassException: net.sf.jasperreports.engine.base.JRBaseReport; local class incompatible: stream classdesc serialVersionUID = 601, local class serialVersionUID = 602 at java.io.ObjectStreamClass.initNonProxy(Unknown Source) at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source) at java.io.ObjectInputStream.readClassDesc(Unknown Source) at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source) at java.io.ObjectInputStream.readClassDesc(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:233) at my.com.shinyang.eply.ui.panels.ReportOptionsPanel.display(ReportOptionsPanel.java:757) at my.com.shinyang.eply.ui.panels.ReportOptionsPanel$2.widgetSelected(ReportOptionsPanel.java:223) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2772) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2431) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1377) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1348) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:254) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at my.com.shinyang.ui.MainWindow.run(MainWindow.java:28) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:335) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:704) at org.eclipse.core.launcher.Main.main(Main.java:688) NESTED BY : java.io.InvalidClassException: net.sf.jasperreports.engine.base.JRBaseReport; local class incompatible: stream classdesc serialVersionUID = 601, local class serialVersionUID = 602 at java.io.ObjectStreamClass.initNonProxy(Unknown Source) at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source) at java.io.ObjectInputStream.readClassDesc(Unknown Source) at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source) at java.io.ObjectInputStream.readClassDesc(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:233) at my.com.shinyang.eply.ui.panels.ReportOptionsPanel.display(ReportOptionsPanel.java:757) at my.com.shinyang.eply.ui.panels.ReportOptionsPanel$2.widgetSelected(ReportOptionsPanel.java:223) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2772) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2431) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1377) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1348) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:254) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at my.com.shinyang.ui.MainWindow.run(MainWindow.java:28) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:335) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:704) at org.eclipse.core.launcher.Main.main(Main.java:688) NESTED BY : net.sf.jasperreports.engine.JRException: Error loading object from InputStream at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:237) at my.com.shinyang.eply.ui.panels.ReportOptionsPanel.display(ReportOptionsPanel.java:757) at my.com.shinyang.eply.ui.panels.ReportOptionsPanel$2.widgetSelected(ReportOptionsPanel.java:223) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2772) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2431) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1377) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1348) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:254) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at my.com.shinyang.ui.MainWindow.run(MainWindow.java:28) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:335) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:704) at org.eclipse.core.launcher.Main.main(Main.java:688) Caused by: java.io.InvalidClassException: net.sf.jasperreports.engine.base.JRBaseReport; local class incompatible: stream classdesc serialVersionUID = 601, local class serialVersionUID = 602 at java.io.ObjectStreamClass.initNonProxy(Unknown Source) at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source) at java.io.ObjectInputStream.readClassDesc(Unknown Source) at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source) at java.io.ObjectInputStream.readClassDesc(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:233) ... 22 more help....!!
|
 |
Alexandru Popescu
Ranch Hand
Joined: Jul 12, 2004
Posts: 995
|
|
It seems that the local object is different than the remote object (retrieved from the jdbc connection (?)). Take a look at using serialVersionUIDs and you'll probably fix it soon. good luck -- ./pope
|
 |
christina ku
Greenhorn
Joined: Jan 06, 2005
Posts: 8
|
|
what does it means by serialVersionUID ? how can i resolve it? is it something wrong with my jasper file that i created using ireport? for your info, i am using ireport 0.4.0 with jasper 0.6.2. please advice. chris
|
 |
Alexandru Popescu
Ranch Hand
Joined: Jul 12, 2004
Posts: 995
|
|
serialVersionUID is a generated no. used while serializing/deserialization of objects for assuring that compatibile bytecode is serialized/deserialized. -- ./pope
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
|
You probably need to recompile your report design file using the same JDK and version of JasperReports you are using at runtime.
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
christina ku
Greenhorn
Joined: Jan 06, 2005
Posts: 8
|
|
|
ok.. solve that already.. Thanks for the advice.
|
 |
kri shan
Ranch Hand
Joined: Apr 08, 2004
Posts: 1248
|
|
|
Hi Christina, How you solved this probelm ? It may be helpful to every-body..
|
 |
christina ku
Greenhorn
Joined: Jan 06, 2005
Posts: 8
|
|
It's simply because the iReport version 0.4.0 is not compatible with jasperreport version 0.6.2. So i change back to using jasperreport version 0.6.1 instead. I think it's something to do with the jasper file generated by ireport which cannot be opened by jasperreport 0.6.2. Just an idea though i am not so sure about that. Good by me as long as it works.. chris
|
 |
 |
|
|
subject: Problem with jasper report -loading stream
|
|
|