Why Is Jasper on the Swing Set Again

Error on loading .jasper file (Urgent)

Hi everybody,

I take a problem on my hands and guess what: its well-nigh jasper.

This is the situation:

while running the side by side code:

--- lawmaking snippit here ----

public JasperReport getCompliledReport(String reportName) throws JRException{

// -- initializing the variables
ResourceLoader loader = new DefaultResourceLoader();
Resource report = null;
File compiledReport = nada;
Object jasperReport = null;

            // -- load the compiled study every bit a resource
report = loader.getResource(JASPER_RESOURCE+reportName);

try{
if(written report != nada){
compiledReport = report.getFile();
}

// -- load the compiled study and make it a jasper Object
// -- then jasper reports tin can work with it.
jasperReport = JRLoader.loadObject(compiledReport.getAbsolutePath());

}
catch(IOException e){
e.printStackTrace();
}

// -- cheque if the object returned by the JRLoader is of type JasperReport
if(jasperReport instanceof JasperReport && jasperReport != null){
return (JasperReport) jasperReport;
}
else
throw new JRException(ResourceKeys.DESIGN_LOAD_FAILED);

}

 --- END OF Lawmaking SNIPPET ----

The exception is thrown at the line in bold.  I go the following stacktrace:

net.sf.jasperreports.engine.JRException: Mistake loading object from file : C:\\co-operative\\target\\classes\\A6page.jasper
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:92)
at internet.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:64)
at be.lisis.pos.impress.jasper.JasperPrinter.getCompliledReport(JasperPrinter.java:165)
at be.lisis.pos.print.jasper.JasperPrinter.impress(JasperPrinter.java:214)
at exist.lisis.pos.print.jasper.A6Printer.consign(A6Printer.java:175)
at be.lisis.pos.impress.jasper.A6Printer.printA6Labels(A6Printer.java:54)
at be.lisis.pos.workflow.label.PrintWFA.processWorkFlowEvent(PrintWFA.java:201)
at exist.ldc.jawfl.wfm.SecurityContext.dispatch(SecurityContext.java:208)
at exist.ldc.jawfl.wfm.AbstractWorkFlowManager.processWorkFlowEventWithException(AbstractWorkFlowManager.java:358)
at be.ldc.jawfl.wfm.AbstractWorkFlowManager.processWorkFlowEvent(AbstractWorkFlowManager.java:341)
at be.ldc.jawfl.gui.AbstractGUIManager.triggerWorkFlowEvent(AbstractGUIManager.java:278)
at be.ldc.jawfl.gui.AbstractGUIManager$WorkFlowEventListener.actionPerformed(AbstractGUIManager.java:2169)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at be.ldc.jawfl.gui.swing.JWorkFlowButton.fireActionPerformed(JWorkFlowButton.java:114)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.coffee:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.coffee:6216)
at javax.swing.JComponent.processMouseEvent(JComponent.coffee:3265)
at java.awt.Component.processEvent(Component.java:5981)
at java.awt.Container.processEvent(Container.coffee:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4583)
at coffee.awt.Container.dispatchEventImpl(Container.coffee:2099)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4556)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4220)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4150)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at coffee.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.coffee:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at coffee.awt.EventDispatchThread.pumpEvents(EventDispatchThread.coffee:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


Caused past: java.io.InvalidClassException: java.util.ArrayList; local course incompatible: stream classdesc serialVersionUID = 8664875232659988799, local grade serialVersionUID = 8683452581122892189
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.coffee:562)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at coffee.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at coffee.io.ObjectInputStream.readSerialData(ObjectInputStream.coffee:1871)
at coffee.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at coffee.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at coffee.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at internet.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.coffee:88)
... 37 more

I am also obliged to give a bit more data:

We utilise jasperreports-maven-plugin to compile whatever jrxml file in a given source directory. Then i try to load the .jasper file so i can fill it with data and apply it.

The problem is not in fetching the resource only in putting the pieces back together after deserialization. it would seem like i have 2 different versions of something (some jar or class or whatever). I find it very odd that the error seems to be about a standard java class (coffee.util.ArrayList), and as far as i know there is non a single ArrayList used either in the code for press the study or in the written report itself.

Some help on fixing this problem would be profoundly appreciated. Whatever more questions or further data that is required, please enquire away. i will exist monitoring my thread ofcourse.

This is quite urgent.

Thanks in advance,

Ocketje

ocketje's picture

Joined: Nov 23 2009 - 6:53am

Last seen: 12 years 5 months agone

cn73's picture

Joined: Jun 29 2009 - 5:22am

Last seen: 12 years 10 months ago

Hi,

It looks like yous are using 1 version of JR to compile the reports and a different JR version to run them.

Normally, this should not be a trouble, merely nosotros demand to know which versions you are using, in case we need to set something.

If you are using quondam versions, you will merely demand to upgrade to the latest.

Thank you,

Teodor

teodord's picture

Joined: Jun 30 2006 - ix:00am

Last seen: one week v days agone

hello cn73.
Thanks for your respond!

Still, i could non yet find a solution. The problem i accept is in a grade i cant access nor alter.

To be precise: information technology happens in the ObjectInputStream class, at i of the readObject() methods.

I deceit alter that grade. Merely still, i read the thread that you refer to in your link, and i learned a lot from information technology.

Basically, his problem was the UTF-viii encoding used to encode his URL. I dont use an URL.

Even so, the UTF-viii encoding makes me recollect...

anyway, cheers for your reply!

ocketje's picture

Joined: Nov 23 2009 - 6:53am

Concluding seen: 12 years 5 months ago

Hello Theodor,

also cheers for your reply.

I am admittedly sure that the version of the compiler tool is equal to the version that our software runs. It had crossed my heed already, so i double checked the POM- file to see if the dependencies matched.

We use jasperreports version two.0.1 both in the maven plugin every bit in our software. This is the POM dependency:

<dependency>
<groupId>jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>2.0.1</version>
</dependency>

All of our reports are made with iReports ii.0.two. Information technology wont be easy to upgrade to the latest jasper version, but suppose nosotros do, won't we have issues with our reports that were generated by iReports? The first thing that comes into my listen are deprecated tags or deprecated java code?

Thank you for your reply.

Regards,

Nicholas

ocketje's picture

Joined: November 23 2009 - 6:53am

Terminal seen: 12 years 5 months ago

hello all again,

I have upgraded the jasper version to iii.5.3 (in my sandsbox) only i still get the same error.

i dont work with customer-server setup here, just maven that builds the project and compiles the jrxml files, then puts it all away in a jar file.

i am sure that the java versions are the same at compile time and at runtime. Everything happens on the same auto btw.

The fault occurs n the following piece of code:

jasperReport = JRLoader.loadObject( compiledReport.getAbsolutePath());

The 'compiledReport' variable you lot see is of the type 'File' and has been fetched as a Resource on which i perform :

resources.getFile(), although i dont think that is part of the crusade.

Any more thought'southward?

greetz,

ocketje

ocketje's picture

Joined: Nov 23 2009 - half dozen:53am

Last seen: 12 years 5 months agone

try put in you pom.xml a backdrop like this:
<project.build.sourceEncoding>UTF-8</projection.build.sourceEncoding>

you don't use URL, but URI (file path??)
attempt it!

cn73's picture

Joined: Jun 29 2009 - v:22am

Final seen: 12 years 10 months ago

Hello cn73!

Cheers for your reply, as information technology was very helpful. I fixed the problem taking your hint.

You are right and information technology was a first-class idea. I figured (from the previous link you sent me) that the trouble was (the trouble of the guy in that specific thread) was an encoding problem. And although i looked at my POM several times, i always missed the fact that there was 1 encoding tag already. Then i never thought the problem could exist about the same. Thank you mate, yous reply was very usefull.

I went looking for some more information and i found the following:

http://docs.codehaus.org/display/MAVENUSER/POM+Element+for+Source+File+Encoding

where it clearly says that changing the encoding for some plugins (specially build plugins) tin can have a huge impact. And then the pieces of the puzzle somewhat started to connect in my caput.

here is the troublesome piece of POM:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.half-dozen</source>
<target>one.half dozen</target>
<maxmem>128m</maxmem>
<encoding>ISO-8859-1</encoding>
</configuration>

</plugin>

This was the only plugin (of 3 defined plugins) that had an encoding tag to explicitly set an encoding. Now, i dont know what the default is, merely i bet information technology is UTF-8.

So i put the encoding to ISO-8859-ane for all of the defined plugins (being: maven-compiler-plugin, maven-resource-plugin (also build plugin) and jasperreports-maven-plugin (not a build plugin, simply very of import i considering my goals) .

I did a clean and build again (in netbeans), relaunched the project and hooray, information technology works like a amuse at present.

Thanks for the fast replies!

Ocketje

ocketje's picture

Joined: Nov 23 2009 - 6:53am

Last seen: 12 years 5 months ago

very good ;) practice I deserve a karma point? ;)

cn73's picture

Joined: Jun 29 2009 - v:22am

Final seen: 12 years 10 months ago

ocketje's picture

Joined: November 23 2009 - 6:53am

Last seen: 12 years 5 months ago

williamstwounds.blogspot.com

Source: https://community.jaspersoft.com/questions/531142/error-loading-jasper-file-urgent

0 Response to "Why Is Jasper on the Swing Set Again"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel