Question

I'm trying to use a .jrtx file saved like a blob.

I'm passing the file .jrtx in this way:

InputStream docStyle = new ByteArrayInputStream(myBean.getDocStyle()); 
map.put("docStyle", docStyle);

While in my file .jrxml i have:

<parameter name="docStyle" class="java.lang.Object"/>

but when jaspet try to fill the report

 JasperFillManager.fillReport(fileToFill, map, dataSuorce);

i get the following error:

Caused by: org.xml.sax.SAXParseException: Premature end of file.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.commons.digester.Digester.parse(Digester.java:1916)
at net.sf.jasperreports.engine.xml.JRXmlTemplateLoader.loadTemplate(JRXmlTemplateLoader.java:195)
... 78 more

How to can I solve it?

Était-ce utile?

La solution

The problem was that when the stream is read once the file offset position counter is moved to the end of file, using the same stream at others times you will get the error. I solved using docStyle.reset();

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top