JasperReports API: calling JasperCompileManager.compileReport (String) method raised the MalformedByteSequenceException exception

前端 未结 3 1727
囚心锁ツ
囚心锁ツ 2020-12-12 03:55
public void openReport() {

    try {
        HashMap params = new HashMap();
        params.put(\"aapor\", 19);

        JasperReport jasperReport1 = JasperCompileM         


        
相关标签:
3条回答
  • 2020-12-12 04:06

    It's a problem with the character codification. Have you tried changing the encoding line at the beginning of the report?

    i.e. for central european alphabet, change:

    <?xml version="1.0" encoding="UTF-8"?>
    

    by

    <?xml version="1.0" encoding="CP1250"?>
    

    You have a list of different character encoding standards here: http://en.wikipedia.org/wiki/Character_encoding#Common_character_encodings

    Hope it works

    0 讨论(0)
  • 2020-12-12 04:19

    You are trying to compile a jasper file already compiled. Replace newReport5.jasper by newReport5.jrxml.

    If you want to work with jasper file directly, you have to do like this :

    JasperReport jasperReport = (JasperReport)JRLoader.loadObject(new File("filename.jasper"));
    
    0 讨论(0)
  • 2020-12-12 04:20

    When does this exception occur (Compile or Execution?). Usually that problem means that your input IS NOT UTF-8.

    If you are entirely sure that it should be UTF-8 try this: 1. Create a NEW EMPTY file and encode it as UTF-8. 2. Copy the whole text from your old file to the new one. 3. Save the new one and check if it works with the new file. If it does, your old file was not proper UTF-8. 4. If not, post your input file (the jrxml.)

    When I have problems like this I try to find the offending character, a HEX Editor helps.

    0 讨论(0)
提交回复
热议问题