Grails jasper pdf net.sf.jasperreports.engine.JRException: Image read failed

1.4k views Asked by At

I'm facing strange error with grails and jasper report. In development everything ok, it can generate pdf successfully.

The problem when I run in production (aws ec2, ubuntu and tomcat7). It throws error:

2014-11-10 05:25:46,604 [http-bio-8080-exec-5] ERROR errors.GrailsExceptionResolver  - JRException occurred when processing request: [GET] /jasper/index
Image read failed.. Stacktrace follows:
net.sf.jasperreports.engine.JRException: Image read failed.  
    at net.sf.jasperreports.engine.util.JRJdk14ImageReader.readImage(JRJdk14ImageReader.java:73)  
    at net.sf.jasperreports.engine.util.JRImageLoader.loadAwtImageFromBytes(JRImageLoader.java:167)  
    at net.sf.jasperreports.engine.JRImageRenderer.getImage(JRImageRenderer.java:418)  
    at net.sf.jasperreports.engine.JRImageRenderer.getOnErrorRendererForImage(JRImageRenderer.java:321)  
    at net.sf.jasperreports.engine.export.JRPdfExporter.exportImage(JRPdfExporter.java:1482)  
    at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:957)  
    at net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:920)  
    at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:797)  
    at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:514)  
    at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:200)  
    at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
    at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53)  
    at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:49)  
    at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:82)  
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
    at java.lang.Thread.run(Thread.java:745)  

I get image from url. Is there something I miss?

Thanks, Didin

1

There are 1 answers

0
user1893425 On

Here's ireport code:

<?xml version="1.0" encoding="UTF-8"?>
<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="sample-jasper-plugin" pageWidth="575" pageHeight="795" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="10" rightMargin="10" topMargin="10" bottomMargin="10" uuid="d8f3e0f1-d2c2-42c1-a2da-b9eaa082d104">
    <property name="ireport.scriptlethandling" value="0"/>
    <property name="ireport.encoding" value="UTF-8"/>
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="112"/>
    <import value="net.sf.jasperreports.engine.*"/>
    <import value="java.util.*"/>
    <import value="net.sf.jasperreports.engine.data.*"/>
    <parameter name="name" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["<parameter error>"]]></defaultValueExpression>
    </parameter>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="375" splitType="Stretch"/>
    </detail>
    <columnFooter>
        <band splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="377">
            <image>
                <reportElement x="0" y="0" width="555" height="375" uuid="ade00ad9-ed14-4c1b-a5ba-4023d9130c8f"/>
                <imageExpression><![CDATA["http://static.appdokter.com/certborder2.jpg"]]></imageExpression>
            </image>
            <textField>
                <reportElement x="129" y="194" width="287" height="28" uuid="290e6e70-d233-470e-b789-0229a95901b7"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Segoe UI" size="20"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{name}]]></textFieldExpression>
            </textField>
            <image>
                <reportElement x="234" y="264" width="82" height="41" uuid="e48c927c-a68b-48f3-a1d9-5c5b9ee9e233"/>
                <imageExpression><![CDATA["http://static.appdokter.com/jansen-logo.jpg"]]></imageExpression>
            </image>
            <image>
                <reportElement x="154" y="58" width="238" height="63" uuid="83d6a162-f0e6-4035-bc70-b45e9c80f65e"/>
                <imageExpression><![CDATA["http://static.appdokter.com/logo.png"]]></imageExpression>
            </image>
            <staticText>
                <reportElement x="129" y="121" width="287" height="25" uuid="fb7db504-e1c4-474a-b78b-8e64127dd260"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Segoe UI" size="18" isBold="true" isItalic="true"/>
                </textElement>
                <text><![CDATA[Certificate Of CME & Education]]></text>
            </staticText>
            <staticText>
                <reportElement x="154" y="146" width="237" height="42" uuid="089bd26d-a76b-46fc-9b5d-5f9cc3be2482"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Times New Roman" size="12"/>
                </textElement>
                <text><![CDATA[BE IT KNOWN THAT APPDOKTER HAS CONFIRMED THAT]]></text>
            </staticText>
            <staticText>
                <reportElement x="154" y="231" width="237" height="31" uuid="436076bf-d5e9-496a-842e-0453a4d90325"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Times New Roman" size="12"/>
                </textElement>
                <text><![CDATA[HAS PASSING CME & EDUCATION TEST WITH EXCELENT SCORE]]></text>
            </staticText>
        </band>
    </summary>
</jasperReport>

But why this code working fine in my local machine, not in aws ec2?