DataMatrix in jasper

0

Hi

I have a big problem, I make a report in jasper, in software the report works using a DataMatrix, but wen i put in the file jrxml in php (framework yii2), a have a error, wen I remove the DataMatrix he back to normal operation

This is the code I use to generate the DataMatrix

<image>
    <reportElement x="257" y="50" width="50" height="50"
                   uuid="0d4a0fa1-0998-457f-8d25-d157bcbc11f4"/>
    <imageExpression>
        <![CDATA[com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage(new com.google.zxing.datamatrix.DataMatrixWriter().encode($F{CodigoDeBarras}, com.google.zxing.BarcodeFormat.DATA_MATRIX,100,100))]]>
    </imageExpression>
</image>

The error in the framework is the 'file is not a valid jrxml file'.

anyone can help ?

Gabriel Nadoroski

gabriel.nadoroski's picture
Joined: Oct 1 2018 - 2:05pm
Last seen: 11 months 2 weeks ago

6 Answers:

0

I found the solution, if you using JasperStarter only atualize the files, just do this he come it work again.

Here is the link where I do the download:

https://sourceforge.net/projects/jasperstarter/


Thanks !

gabriel.nadoroski's picture
Joined: Oct 1 2018 - 2:05pm
Last seen: 11 months 2 weeks ago
0

In the Studio, your expression works fine with dependencies.

Check if you are missing these dependencies in your framework. 

 

    <import value="com.google.zxing.*"/>
    <import value="com.google.zxing.client.j2se.*"/>

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.2.final using JasperReports Library version 6.4.1  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="dataMatrix" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="3b05d319-6bc1-41cc-9f50-1733cb19849f">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <import value="com.google.zxing.*"/>
    <import value="com.google.zxing.client.j2se.*"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="61" splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="210" splitType="Stretch">
            <image>
                <reportElement x="0" y="0" width="300" height="210" uuid="548ff446-5c8b-4d33-a2ce-9553abfad2fb"/>
                <imageExpression><![CDATA[com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage(new com.google.zxing.datamatrix.DataMatrixWriter().encode("123456789", com.google.zxing.BarcodeFormat.DATA_MATRIX,100,100))]]></imageExpression>
            </image>
        </band>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

reportdev's picture
1222
Joined: Oct 12 2015 - 12:05pm
Last seen: 3 months 1 week ago
0

Thanks for the answer, but don't work, I tried put thie import in the file and i tried put the same code you sended, both don't work, he get the same error.
The problem is, I have to do the report with the DATAMATRIX, I tried use the DATAMATRIX of jasper, but have a bug, when I put the field of barcode and select the datamatrix, field show just a bean and stop the software, like a ghost field I can't edit the field, I have reniciate the software to he back to normal work.

You have any Idea to fix that error ? 

gabriel.nadoroski's picture
Joined: Oct 1 2018 - 2:05pm
Last seen: 11 months 2 weeks ago
0

I think its the dependencies causing this error  'file is not a valid jrxml file'.

Add all these dependencies. if it fails again with these dependencies... post the entire log and jrxml.

jasperreports-6.4.2.jar

jasperreports-fonts-6.1.1.jar

jasperreports-functions-6.4.2.jar

 

 

reportdev's picture
1222
Joined: Oct 12 2015 - 12:05pm
Last seen: 3 months 1 week ago
0

This dependencies I put on jasper ?
I think can't put this on php.

I'm using the jasper 6.6.0,  the jars of another version made missing in this version ?

And about post the jrxml, I need the modify somethings, because I can't post everything ofthe jrxml, somethings is confidential, I will see with my equipe what's I can post here, and I edit this post and put here.
I will try put these jars, thanks.

 

gabriel.nadoroski's picture
Joined: Oct 1 2018 - 2:05pm
Last seen: 11 months 2 weeks ago
0

This is the error when I select the barcode in palette and after select the DataMatrix, when I try to save or change to the source or preview, this error appear.

java.lang.RuntimeException: java.lang.NullPointerException
    at net.sf.jasperreports.eclipse.builder.JasperReportCompiler.compileReport(JasperReportCompiler.java:304)
    at com.jaspersoft.studio.editor.preview.view.control.ReportController.compileJasperDesign(ReportController.java:467)
    at com.jaspersoft.studio.editor.preview.view.control.ReportController.access$8(ReportController.java:452)
    at com.jaspersoft.studio.editor.preview.view.control.ReportController$1.run(ReportController.java:376)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
Caused by: java.lang.NullPointerException
    at net.sf.jasperreports.engine.component.ComponentsEnvironment.getManager(ComponentsEnvironment.java:159)
    at net.sf.jasperreports.engine.JRExpressionCollector.collect(JRExpressionCollector.java:1639)
    at net.sf.jasperreports.engine.design.JRDesignComponentElement.collectExpressions(JRDesignComponentElement.java:99)
    at net.sf.jasperreports.engine.JRExpressionCollector.collect(JRExpressionCollector.java:1618)
    at net.sf.jasperreports.engine.design.JRDesignFrame.collectExpressions(JRDesignFrame.java:95)
    at net.sf.jasperreports.engine.JRExpressionCollector.collect(JRExpressionCollector.java:801)
    at net.sf.jasperreports.engine.JRExpressionCollector.collect(JRExpressionCollector.java:772)
    at net.sf.jasperreports.engine.JRExpressionCollector.collect(JRExpressionCollector.java:755)
    at net.sf.jasperreports.engine.JRExpressionCollector.collect(JRExpressionCollector.java:1542)
    at net.sf.jasperreports.engine.JRExpressionCollector.collect(JRExpressionCollector.java:629)
    at net.sf.jasperreports.engine.JRExpressionCollector.collector(JRExpressionCollector.java:119)
    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:149)
    at net.sf.jasperreports.eclipse.builder.JasperReportCompiler.compileReport(JasperReportCompiler.java:286)
    ... 4 more

Anyone knows how fix that error ?
 

gabriel.nadoroski's picture
Joined: Oct 1 2018 - 2:05pm
Last seen: 11 months 2 weeks ago
Feedback
randomness