Jump to content
Changes to the Jaspersoft community edition download ×

Invalid byte 1 of 1-byte UTF-8 sequence.


ozwolverine

Recommended Posts

Hello everybody,

 

I'm having this error message when I try to compile my report :(, the error message is:

 

net.sf.jasperreports.engine.JRException: Invalid byte 1 of 1-byte UTF-8 sequence.

 

What could this means?

 

I have found a couple of messages in the forum with the same subject, but some of them talk about changing encoding to ISO-8859-1, but that doesn't solve the problem.

 

Does anyone know what to do?

 

Thanks a lot,

Johnny

Link to comment
Share on other sites

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

I started to make my reports with iReport-1.2.3, as well as my implementation in java with jasperreports-1.2.0.

 

Then someone gave me some advice on how to export to csv, and he told me about to use a specific class but that class wasn't in those versions I was working on, so I downloaded the last version for iReport (1.2.5) and jasperreports (1.2.5), after that, I was able to follow his instructions to export the report to cvs, but on the first stage (compilation of the report .jasper), I got the mentioned error message.

 

I read some forum messages and they talked about changing enconding from UTF-8 to ISO-8859-1, but that didn't work either. So now I don't know what could the problem be.

 

Your help would be very appreciated :)

 

thanks a lot,

Johnny

Link to comment
Share on other sites

Be careful, if you manually change the encoding in the JRXML, for example to ISO-8859-1:

 

<?xml version="1.0" encoding="ISO-8859-1" ?>

 

and then load the file again in iReport, it is changed to UTF-8 again. But it only changes the encoding attribute, not the encoding of the file itself!

 

I don't know if this is really bug of iReport or just a result of how the file and the XML is processed in some underlying layers/libraries.

Link to comment
Share on other sites

But do you think, this is really encoding related problem? I mean, I changed the encoding manually, and as you said it is changed back automatically to UTF-8, so I changed the encoding through iReport to ISO-8859-1, but I'm having the same problem. So I guess that must be some kind of bug. Do you know what could be causing the problem?

 

 

Thanks,

Johnny

Link to comment
Share on other sites

Can you upload the jrxml you are working on? I'll take a look and see if it appears as valid UTF-8 or some other character set. From what you are saying it sounds like it should be UTF-8. What OS are you running - could make a difference depending on the file system.

 

-Barry

Link to comment
Share on other sites

Hello, this is the jrxml file, once I changed the encoding from utf-8 to iso-8859-1 using: ( Edit, Report Properties, i18n ), the accents (from my mother language, spanish) I had in my report.

 

I created the report with ireport 1.2.3, but I last saved with 1.2.5.

 

 

 

thanks a lot,

Johnny [file name=UsuariosRegistradosFechas.jrxml size=14940]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/UsuariosRegistradosFechas.jrxml[/file]

Link to comment
Share on other sites

Look at this staticText element:

 

Code:
<staticText>
<reportElement ... key="element-90"/>
<box ... />
<textElement>
<font fontName="" size="12"/>
</textElement>
<text><![CDATA[identificación]]></text>
</staticText>

 

The text is encoded in UTF-8, not ISO-8859-1! Could it be possible, that you used several editors to edit the file?

Maybe one of them is setted to store in UTF-8 by default. I can remember at least one editor that changes and stores the file content to UTF-8 automatically by default in such a case, independent of the encoding before.

The result is just a mangled file, in the worst case you have a mix of encodings for special chars in the file.

Link to comment
Share on other sites

Alexander is right, the file isn't ISO-8859-1. It looks to be UTF-8 with no byte order mark. I'm not sure why you got an error in the first place and changed the encoding. I just changed the encoding in the file to UTF-8 and it compiled correctly.

 

Try setting encoding in both the first line and in the ireport.encoding property to UTF-8 and try again. If it complains about the first byte of a UTF-8 character post some details about your environment, such as the version of the JVM, the OS you are using, etc.

 

-Barry

Link to comment
Share on other sites

Thanks Barry and Alexander,..

 

I will do what Barry says, Hope to have good news soon. Let's see if this is a bug or just a misconfigured environment.

 

BTW, my environment is:

 

Windows XP Media Center SP2

jdk-1.5.0_06

Eclipse 3.1.2

iReport 1.2.3 and 1.2.5

Jassper Reports 1.2.5

 

Web app with:

JSF

EJB3

Jboss-4.0.4.GA

 

Am I missing something? :)

 

 

Thanks a lot for you interest,

Johnny

Link to comment
Share on other sites

Sorry, I keep getting the same error message:

 

20:33:55,683 ERROR [ReporteUsuariosRegistradosBean] net.sf.jasperreports.engine.JRException: Invalid byte 1 of 1-byte UTF-8 sequence.

20:33:55,683 INFO [ReporteUsuariosRegistradosBean] Invalid byte 1 of 1-byte UTF-8 sequence.

 

 

I thought It could be because I have my eclipse 3.1.2 configured to use ISO-8859-1, so I changed the encoding in Eclipse, but I have the same problem :(

 

I have no clues about this.

 

Thanks for your help,

Johnny

Link to comment
Share on other sites

Note: I'm from Germany, so i'm familiar with the problem of special chars. Not only in having correct encodings in JRXML files. And my experience with Eclipse related to encoding stuff is: it's ugly, it's intransparent. Never use Eclipse to change or repair encodings in texts. (That's not Eclipse specific, the most IDEs seem to be the wrong tools for this task)

 

Use a relativ simple editor (i use ConText). Open the file in the editor and remove the CDATA sections and texts in the static text boxes. Save the file and try to compile it.

 

If it works, go back to the editor and add the texts again. ConText stores the file in ISO-8859-1 by default, so take care of setting

<?xml version='1.0' encoding='ISO-8859-1' ?>

 

Compile again, if it works, be happy and be careful, if you touch the JRXML in the future again.

 

If it does not compile with empty text boxes, then you may have unusal chars somewhere in the file. You could enable ConText feature to show you unprintable chars in the file and look over it. But i guess (seeing the file size) this would require pratically more time then setting up a new report template from scratch.

Link to comment
Share on other sites

Hello Alexander,

I followed your suggestions but it didn't get any positive result.

I removed all cdata sections as well as text in static text elements, but nothing new happened. I also try using both encodings from the iReport interface: UTF-8 and ISO-8859-1, but everything went the same :(

 

I tried passing the jasper file in different ways to the compileReport method, the old way as a String with the full path, next as a FileInputStream, but with the second option the error message is just a bit different:

 

12:02:52,375 ERROR [ReporteUsuariosRegistradosFechaActualBean] net.sf.jasperreports.engine.JRException: Invalid byte 2 of 3-byte UTF-8 sequence.
12:02:52,375 INFO [ReporteUsuariosRegistradosFechaActualBean] Invalid byte 2 of 3-byte UTF-8 sequence.

 

 

 

So I just kept with the original way, with a String.

 

I tryed making a new report, with just a select to display only one column, the sentence is:

 

select * from usuarioempresa

 

Showing in the details section the ID of the user (usuarioempresa:id_usuarioempresa).

 

I tryed with all options, UTF-8, ISO-8859-1, from iReports and from my web app, but the error keeps appearing in my app. But everything goes perfect in iReport.

 

I was wondering if there's any way to set locale for the report programmatically, the question is because I saw that in iReport console I have this output:

 

Compiling to file... .prueba.jasper -> C:Program FilesJasperSoftiReport-1.2.5prueba.java
it.businesslogic.ireport.ReportClassLoader@b0f6ef
Compilation running time : 109
Filling report...
Locale: español (Colombia)
Time zone: default
Report fill running time : 47 (pages generated: 1)
Exporting xls to file (using POI)... .prueba.xls
Export running time : 31
Executing: C:Program FilesOpenOffice.org 2.0programscalc.exe .prueba.xls

 

 

And as you can see, I don't know how, but iReport compiles ok, and pass a Locale and a Time Zone options to the filling of the report. So I was thinking the problem starts there, but I don't know, because locale setting goes after compilation, or at least that is what the console says.

 

What do you think?

 

Thanks a lot,

 

Johnny

 

I was writting this message the I accidentaly pressed my navigator back button and I lost everything. So I had to rewrite it all.

Link to comment
Share on other sites

Via JRParameter.REPORT_LOCALE.

But this parameter is relevant for the export only AFAIK.

 

I would agree with Barry, there seems to be a problem in the underlying enviroment.

 

You say in iReport, everything is ok, but at the stage/developer deployment level the error occurs. Do you run the processing of the report under the application server? They often use some "strange" settings and come with their own libs.

Link to comment
Share on other sites

Yep, I missed to tell you an important part of my environment, I deploy my applications under jboss-4.0.4.GA. I'm going to check if it has another jar inside its libs directories, but I don't think so. No matter that, I'm going to do other tests:

  • I'm going to try to deploy my application under linux to see if theres any difference.

[/ul]

  • I'm going to make a small console app, to see if the problem is with my application server (jboss)

[/ul]

 

I will tell you the results.

 

Thanks a lot,

Johnny

Link to comment
Share on other sites

ozwolverine wrote:

Yep, I missed to tell you an important part of my environment, I deploy my applications under jboss-4.0.4.GA. I'm going to check if it has another jar inside its libs directories, but I don't think so. No matter that, I'm going to do other tests:
  • I'm going to try to deploy my application under linux to see if theres any difference.
    [/ul]

 

I set my environment under Linux, trying different configurations, UTF-8, ISO-8859-1, even I tryed compiling my project with a different IDE, JDeveloper 10g, but I didn't get any positive result :(.

  • I'm going to make a small console app, to see if the problem is with my application server (jboss)
    [/ul]

 

The tests I did on Linux where outside of any application server, it was just a simple java app, trying to load and compile my .jasper file, hoping that the problem was about my jboss app server, but after the test I know that is not the problem :(

 

Do you, Alexander or Barry, have any other ideas?

 

Thanks a lot for your usual help.

 

Johnny

 

P.S: Sorry about the delay, but I was totally busy, and couldn't get time to make the tests before.

Link to comment
Share on other sites

bklawans wrote:

I'm at a loss as what could be going on here. I can compile the file you attached in a previous post without any trouble on my machine. Definitely something in your environment, but I'm not sure what.

Do you have access to another system to test on?

-Barry

 

Hello Barry,

 

I think your comment is very important, that means it must be a problem in my environment.

 

- Is your java code equals as mine? I guess it is,

- Should I upload my java class for you to test it?

- What IDE are you using to compile the .jasper file from de Java class?

 

- What is the configuration you have for locale, language, i18n, etc, in your system?

- What OS are you using?

 

I guess that if my environment settings are the main problem, all these information is very valuable to get a solution :-)

 

Thanks a lot,

 

Johnny

Link to comment
Share on other sites

  • 10 months later...

Hi,

 

If you are still having the same problem, check if you have any .jasper files in the directory containing your .jrxml files that you are trying to compile.

 

I had the same problem. Make sure that you save your .jasper in a separate folder which is NOT a subfolder of the one that contains the .jrxmk files that you trying to compile.

 

Code:

<jasperReportCompile
srcdir="${report.src.dir}"
destdir="${www.dir}/reports"

 

Regards,

 

Ashraf

Link to comment
Share on other sites

  • 1 month later...

Hi. I'm having the same problem; followed your recomendation but it continued to happen. I only have the problem in one of my reports. Generating from the jrxml in java (all in runtime) works well, also generating a preview in iReport (empty data source) also works. The problem is happening when loading a precompiled jasper; which was generated (from the jrxml) in iReport with the default compiler and also javac (tools.jar from the jdk).

 

Any other idea?

 

Thanks in advance.

Link to comment
Share on other sites

rgamarra wrote:

Hi. I'm having the same problem; followed your recomendation but it continued to happen. I only have the problem in one of my reports. Generating from the jrxml in java (all in runtime) works well, also generating a preview in iReport (empty data source) also works. The problem is happening when loading a precompiled jasper; which was generated (from the jrxml) in iReport with the default compiler and also javac (tools.jar from the jdk).

Any other idea?

Thanks in advance.

 

I was the problem. I was trying to compile twice the report! Sorry for the post.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...