java - JRException: Invalid byte 1 of 1-byte UTF-8 sequence -
i trying generate report using jasper reports, getting following error.
net.sf.jasperreports.engine.jrexception: com.sun.org.apache.xerces.internal.impl.io.malformedbytesequenceexception: invalid byte 1 of 1-byte utf-8 sequence.
i using java code:
list<aluno> lista = alunoservice.findall(); string path = req.getsession().getservletcontext().getrealpath("web-inf"); jasperreport report = jaspercompilemanager.compilereport(path + "/relatorios/aluno.jasper"); jasperprint print = jasperfillmanager.fillreport(report, null, new jrbeancollectiondatasource(lista)); jasperexportmanager.exportreporttopdffile(print, path + "/relatorios/teste.pdf");
the error ocurring when try compile report:
jasperreport report = jaspercompilemanager.compilereport(path + "/relatorios/aluno.jasper");
the aluno.jrxml file in utf-8 enconding:
<?xml version="1.0" encoding="utf-8"?>
i've researched problem, reason because jrxml filw not in utf-8 enconding. if me, thank.
java code using aluno.jrxml
list<aluno> lista = alunoservice.findall(); string path = req.getsession().getservletcontext().getrealpath("web-inf"); jasperdesign design = jrxmlloader.load(path + "/relatorios/aluno.jrxml"); jasperreport report = jaspercompilemanager.compilereport(design); jasperprint print = jasperfillmanager.fillreport(report, null, new jrbeancollectiondatasource(lista)); jasperexportmanager.exportreporttopdffile(print, path + "/relatorios/teste.pdf"
the fact have <?xml version="1.0" encoding="utf-8"?>
@ beginning of file doesn't mean file stored in utf-8 encoding, means "i swear file has encoding".
do have in file characters other classic ascii? (something spanish n tilde on it?)
try opening file decent editor , save again, choosing explicitly encoding utf-8 and after have @ special characters inside file see if still same.
Comments
Post a Comment