agmoyano / node-jasper

JasperReports from Node.js
84 stars 52 forks source link

in_memory_json #6

Closed RobertPrediger closed 6 years ago

RobertPrediger commented 9 years ago

I have a report definition with 'in_memory_json'. After calling, I get this error:

error: Error creating class
portal-dev-0 (err): net.sf.jasperreports.engine.JRException: 
com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 middle byte 0x74
portal-dev-0 (err):  at [Source: java.io.ByteArrayInputStream@59578c79; line: 1, column: 90]
portal-dev-0 (err):     at net.sf.jasperreports.engine.data.JsonDataSource.<init>(JsonDataSource.java:108)
portal-dev-0 (err):     at net.sf.jasperreports.engine.data.JsonDataSource.<init>(JsonDataSource.java:91)
portal-dev-0 (err):     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
portal-dev-0 (err):     at   sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
portal-dev-0 (err):     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
portal-dev-0 (err):     at java.lang.reflect.Constructor.newInstance(Constructor.java:534)

What can I do to avoid this behaviour? If you need more info, tell me. ;)

Thanks Robert

agmoyano commented 9 years ago

Hello Robert,

Seems data in your json has non utf-8 characters.

You should convert it manually to utf-8 or use iconv to do it, before you use it with node-jasper.

Hope it helps.

RobertPrediger commented 9 years ago

But this happens only, if I put a data: {} inside.

This is fine (but creating an empty pdf-file):

    var report  = jasper.pdf( {
        report:     repName,
        dataset:    data
    } );

This one is producing this error:

   var report  = jasper.pdf( {
        report:     repName,
        data:       {},
        dataset:    data
    } );
RobertPrediger commented 9 years ago

Now I have it. You have problems with converting data to Java.

If you take your example and put a German umlaut inside (in utf-8 format, example "ä"), than you'll get this error.

How can ve avoid this?

agmoyano commented 9 years ago

Hi Robert, that's weird... could you give me a full example so I can run it and see what's wrong?

Thanks.

El lun., 30 de marzo de 2015 a las 16:09, Robert Prediger (< notifications@github.com>) escribió:

Now I have it. You have problems with converting data to Java.

If you take your example and put a German umlaut inside (in utf-8 format, example "ä"), than you'll get this error.

How can ve avoid this?

— Reply to this email directly or view it on GitHub https://github.com/agmoyano/node-jasper/issues/6#issuecomment-87794552.

RobertPrediger commented 9 years ago

Hi,

just simply add an "ä" in one of the strings in data in your example. This should produce this error.

Thanks!

Best regards Robert

RobertPrediger commented 9 years ago

Just use this:

[{ 
    name: 'Gonzalo',
    lastname: 'Vinasä'   // here is an umlaut
}, {
    name: 'Agustin',
    lastname: 'Moyano'
}]
OmarKafer commented 2 years ago

Hi,

I think the problem continues when using ToJsonDataSource method, cause you changed just the processConn method but not toJsonDataSource method, which is using the old code and giving the same error with UTF-8.

I would really appreciate if you can change this. Really thanks in advance for the plugin !!! :)

BR.

OmarKafer commented 2 years ago

Hi,

This works! (commented the old part and using the same as processConn)

Captura de Pantalla 2022-11-08 a las 9 36 26

I cannot pull the project in order to do a Pull Request because from my Git Client I just can pull organization projects... :( Sorry.

Thanks in advance !!