ERROR : Invalid byte 1 of 1-byte UTF-8 sequence

0

Hi guys,

I just started using the new iReport 3.1.1nb and I must say it is really good !

I just had a major/severe problem with my report, and I am quite disappointed about that...

Here we go :

Error loading the report template
 
Message:
    net.sf.jasperreports.engine.JRException: org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.

Level:
    SEVERE

Stack Trace:
org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.
    net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:243)
    net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:226)
    net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:214)
    com.jaspersoft.ireport.designer.JrxmlLoader.reloadJasperDesign(JrxmlLoader.java:80)
    com.jaspersoft.ireport.designer.JrxmlVisualView.run(JrxmlVisualView.java:485)
    org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561)
    org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986)
Invalid byte 1 of 1-byte UTF-8 sequence.
    com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    org.apache.commons.digester.Digester.parse(Digester.java:1647)
    net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:239)
    net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:226)
    net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:214)
    com.jaspersoft.ireport.designer.JrxmlLoader.reloadJasperDesign(JrxmlLoader.java:80)
    com.jaspersoft.ireport.designer.JrxmlVisualView.run(JrxmlVisualView.java:485)
    org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561)
    org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986)

 

It happened at a random time when I opened a specific report after closing iReport for a simple reboot. Since my report XML file is quite big, it is really hard for me to find the wrong code line in all those XML codes.

Please help !

Thank you

Charles M.

CharleyDC5's picture
Joined: Mar 31 2008 - 4:06am
Last seen: 1 year 7 months ago

19 Answers:

1

It really looks like a problem in my XML code...

Do you guys know a validator where I could put my code and then see what happen with it ?

I wish iReport had a debug mode :(

Thank you VERY MUCH for help

Charles M.

CharleyDC5's picture
Joined: Mar 31 2008 - 4:06am
Last seen: 1 year 7 months ago
0

For you information,

The only way I have found to fix the problem is to install the following plugin from the Tools > Plugins menu :

XML and Schema
Version : 1.0.1

By installing this plugin, the version of the IDE changed to 1.2.3.

Is it a common problem from the 1.0.2 IDE version ?

CharleyDC5's picture
Joined: Mar 31 2008 - 4:06am
Last seen: 1 year 7 months ago
0

I have posted a similar trouble on jasperserver forum and I was answered that it has been transmitted as bug.

Your work-aroundis very interesting

Gaby38's picture
339
Joined: Mar 22 2008 - 1:49am
Last seen: 11 years 2 days ago
0

I just ran into the same problem.  Saved my report, got out to go to a meeting.  Restarted iReport and got the error.

I installed the Plugin XML and Schema as suggested and...  I don't get the error but now it sits there saying Loading Report in the Report Inspector.

- Eric

 

 

 

 

emillerphx's picture
Joined: Jan 31 2008 - 10:06pm
Last seen: 11 years 1 month ago
0

Quick update.  I went in and uninstalled XML and Schemaand now it works just fine.

I am not a Java guy so I'm clueless as to what I just did.  But it looks like that fixes it.

Eric

 

emillerphx's picture
Joined: Jan 31 2008 - 10:06pm
Last seen: 11 years 1 month ago
0
OK, unfolding here. I got in there an noticed that my $-signs were showing up as blocks... looking at the pattern some weird character was defined. I changed it to a $ and now everything looks good.
emillerphx's picture
Joined: Jan 31 2008 - 10:06pm
Last seen: 11 years 1 month ago
0

I'm glad it fixed the problem for you guys !!

I find it very hard to troubleshoot that kind of error. I think we must have a debugger tool in the next version of iReport-nb. It is not that bad when the report only has 50 XML lines, but when you have a crosstab and 3 subreports, this is really a pain to fix.

Probably the new NetBeans IDE version has a new version of the SAX Parser, which is handling some more UTF8 sequences.

Theodor, Giulio ? Any idea ?

Thank you guys

Charles M.

CharleyDC5's picture
Joined: Mar 31 2008 - 4:06am
Last seen: 1 year 7 months ago
0

emillerphx
Wrote:

OK, unfolding here. I got in there an noticed that my $-signs were showing up as blocks... looking at the pattern some weird character was defined. I changed it to a $ and now everything looks good.

Yeah I had the same problem. You just need to re-do the pattern operation on your currency field and the $ signs will come back to normal.

Probably the pattern changed in the new IDE.

CharleyDC5's picture
Joined: Mar 31 2008 - 4:06am
Last seen: 1 year 7 months ago
0

I confirm that installing the plugin XML and Schema fixed the problem for me. Previously "corrupted" reports can now be loaded in editor.As already said, this installation forces the upgrade of the IDE environment.

In fact my error was "Invalid byte 2 of 3-byte UTF-8 sequence" and not "1 of 1-byte UTF-8 sequence" but I think that the troublr source is the same.

Gaby38's picture
339
Joined: Mar 22 2008 - 1:49am
Last seen: 11 years 2 days ago
0

Hi folks,

Hope you are doing fine.

Here is my problem : I work on a report containing a crosstab. That crosstab is populated by a SQL query runned in a dataset. Everything's perfect, but I only have one tiny problem, which is quite annoying. I am unable to hide/remove a full blank line in my crosstab (see the screenshot for more information).

Some will probably say : Why are you adding a blank record in your query results ?
Answer : Well, this is a specific situation. I will try to make it easy to understand. Here we go :

For instance you have a list of laptops in a crosstab. You will need a row group on the serial number, and a column group on the laptops brands.

Let's say you want to list all laptops in a region, for every location/office.

• Office A only has HP and Dell laptops
• Office B only has HP and Lenovo laptops

The problem : You want to show all laptop brands, even if a location doesn't have that laptop brand. (see the second screenshot/image for more information). To achieve it, I add a NULL record in my SQL temp table, representing laptop brands that are missing in the office.

Example : Office A has a NULL record with the Lenovo brand, and Office B has a NULL record with the Dell brand.

This is the only way I found to always print all the columns in the crosstab. Otherwise, the crosstab wasn't showing the NULL columns since it is not available in the SQL query results (raw data).

I just want to hide that null row and eliminate the spacer it creates.

Every field in the crosstab details has Remove Line When Blank checked. As you can see, the line has nothing printed. Now, I just need to hide it for esthetic purpose.

Thank you in advance for help

Charles M.

CharleyDC5's picture
Joined: Mar 31 2008 - 4:06am
Last seen: 1 year 7 months ago
0

Sorry for the last reply... I just wanted to create a new discussion in the iReport Discussion/Help section.

I can't delete it so.. maybe Administrator could delete it ..

Thank you !

Charles M.

CharleyDC5's picture
Joined: Mar 31 2008 - 4:06am
Last seen: 1 year 7 months ago
0

Gaby38
Wrote:

I confirm that installing the plugin XML and Schema fixed the problem for me. Previously "corrupted" reports can now be loaded in editor.As already said, this installation forces the upgrade of the IDE environment.

In fact my error was "Invalid byte 2 of 3-byte UTF-8 sequence" and not "1 of 1-byte UTF-8 sequence" but I think that the troublr source is the same.

 

This also solved my problem thankfully!

However instead of installing the "XML and Schema" plugin, you may just install the "IDE Platform" plugin which is ultimately what solves the problem without having to install the extra plugin unless you need / want it. =)

-Scott

 



Post Edited by Scott Nemes at 01/09/09 20:36
scottn's picture
6
Joined: Jan 9 2009 - 12:31pm
Last seen: 10 years 2 months ago
0

Hello all.

First of all sorry for my english. I'm Spanish and don´t speak english very well.

I'm using iReport nb just for designing the jrxml and then I compile the xml anf create the pdf by java using IBM Websphere and Eclipse IDE.

I have the same problem but I think that the installation of XML and Schema plugin is for NetBeans, isn't it?

Do you have an idea of what is happening?

I've notice that the error appears when i re-open the xml with iReport and save it. If I open then the xml with UltraEdit and directly i save it, the error dissapear.

Thanks a lot.

tunonale's picture
Joined: Jan 16 2009 - 12:37am
Last seen: 10 years 2 months ago
0

Hi, I'm using iReport 3.0.0 and using Netbeans 6.5. I've encountered the problem below. The XML and Schema have already installed. May I know what problem do I have? Below are the codes..

net.sf.jasperreports.engine.JRException: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.

.

.

.

.

.

.
 

Code:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
package servlets;
 
import java.io.*;
 
import java.sql.DriverManager;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.Connection;
//import java.util.HashMap;
//import java.util.Map;
 
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.JasperReport;
 
/**
 *
 * @author Techprenuer
 */
public class Report_JobSpecBar extends HttpServlet {
 
    /**
    * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        // TODO code application logic here
       Connection connection = null;
 
       ServletOutputStream servletOutputStream = response.getOutputStream();
 
       File reportFile = new File(getServletConfig().getServletContext()
                 .getRealPath("/WEB-INF/reports/JobCategorybySpecializationBarChart.jasper"));
 
        //Map<String, Object> params = new HashMap<String, Object>();
        //params.put("reportTitle", "Company Job Adverts");
        //params.put("author", "Melissa");
       // params.put("startDate", (new java.util.Date()).toString());
 
 
 
       try {
            Class.forName("com.mysql.jdbc.Driver");
 
            connection = DriverManager
                    .getConnection("jdbc:mysql://localhost:3306/studentemploymentdb", "root", "dell0208");
 
            //bytes = JasperRunManager.runReportToPdf(reportFile.getPath(),
                     //params, connection);
 
            JasperDesign jasperDesign = JRXmlLoader.load(reportFile.getPath());
            JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
            JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, connection);
            byte[] bytes = JasperExportManager.exportReportToPdf(jasperPrint);
 
 
 
 
 
 
 
            response.setContentType("text/html");
            response.setContentLength(bytes.length);
 
            servletOutputStream.write(bytes, 0, bytes.length);
            servletOutputStream.flush();
            servletOutputStream.close();
 
            connection.close();
       }
       catch (Exception e) {
            // display stack trace in the browser
            StringWriter stringWriter = new StringWriter();
            PrintWriter printWriter = new PrintWriter(stringWriter);
            e.printStackTrace(printWriter);
            response.setContentType("text/plain");
            response.getOutputStream().print(stringWriter.toString());
       }
    }
 
    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
    * Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }
 
    /**
    * Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }
 
    /**
    * Returns a short description of the servlet.
    */
    public String getServletInfo() {
        return "Short description";
    }
 
 
    // </editor-fold>
}
</td></tr></tbody></table>
jin9jun's picture
Joined: Jan 7 2009 - 6:32pm
Last seen: 10 years 2 months ago
0

 Do you know where I could get the plug-in XML and Schema 1.2.3? I cannot find the plugin in the netbeans website. Thanks!

ian11976's picture
Joined: Apr 7 2011 - 11:42pm
Last seen: 7 years 11 months ago
0

 Here is the exception. I hope someone can help me.

 

net.sf.jasperreports.engine.JRException: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.

        at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:249)

        at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:228)

        at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:216)

        at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:170)

        at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:154)

        at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:146)

        at com.lps.form.JFrameReportTest.<init>(JFrameReportTest.java:40)

        at com.lps.form.JFrameReportTest$2.run(JFrameReportTest.java:140)

        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)

        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)

        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)

        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)

        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.

        at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:684)

        at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:554)

        at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1742)

        at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.arrangeCapacity(XMLEntityScanner.java:1619)

        at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipString(XMLEntityScanner.java:1657)

        at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:193)

        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)

        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)

        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)

        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)

        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)

        at org.apache.commons.digester.Digester.parse(Digester.java:1647)

        at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:241)

        ... 15 more

ian11976's picture
Joined: Apr 7 2011 - 11:42pm
Last seen: 7 years 11 months ago
0

I have the same error, check the jrxml using a text editor but select the utf-8 encoding then you can see if there are some character inapropied for the utf-8 encoding.

jaime.pegueroles's picture
Joined: Jun 27 2013 - 2:25pm
Last seen: 1 year 9 months ago

I had a similar problem with iReport using xpath queries to an XML file. I changed the file encoding to UTF -8 with Notepad ++ and problem solved .

gadasmef - 4 years 3 weeks ago

Yes that is another way to find an issue in the xml...good one!

jaime.pegueroles - 2 years 10 months ago
0

By Abhishek

Hello ,

I have experianced the same error while runnig reports on Jasperserver.

What I did is to delete those reports from Jasperserver and upload it again,

I know It sound stange but It works for me.

 when we try to replace the reports from IReport to Jasper Repository, Specially in the case of the Main Report which contain the reference of subreport. I think this may be the case where reports are not able to replace completely and it cause that error.

Thanks

Abhishek



Post Edited by abhishekverma18 at 09/30/2011 06:11

 

(i do as what say above and it is work, just remove the Report  and add it again, the Report i have, have subReport)

myasit's picture
2
Joined: Feb 3 2015 - 1:57am
Last seen: 3 years 9 months ago
0

sorry to say that i have not solved the issue.i tried with installing the plugins but the problem remains same.could anyone help me .

net.sf.jasperreports.engine.JRException: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.
at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:306)
at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:285)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:274)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:219)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:194)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:185)
at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:288)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:575)
chandrasekhar@geceindia.com's picture
Joined: Nov 25 2015 - 4:20am
Last seen: 3 years 6 days ago
Feedback
randomness