Marcin Erbel Marcin Erbel - 5 months ago 127
Java Question

net.sf.jasperreports.engine.JRException: Byte data not found

I'm trying to pass to template of a jasper reports string location. So I'm passing key of a parameter inside template and value. Everything was working when I had image inside my project, but I would like to have it on the other place. Is there any way to read parameters from, for instance properties file? I don't know why this sollution is not working:

My image:

<parameter name="imagesDir" class="java.lang.String" isForPrompting="false"/>


...

<image isLazy="true">
<reportElement key="image-1" style="PHLabel" x="0" y="0" width="160" height="33"/>
<imageExpression class="java.lang.String"><![CDATA["$P{imagesDir}"+"logo.bmp"]]></imageExpression>
</image>


error:

Error during exporting report statement_account_10 to PDF.
net.sf.jasperreports.engine.JRException: Byte data not found at :
((java.lang.String)parameter_imagesDir.getValue())logo.bmp

Answer

Ok i found it... Should be:

<image isLazy="true">
    <reportElement key="image-1" style="PHLabel" x="0" y="0" width="160" height="33"/>
    <imageExpression class="java.lang.String"><![CDATA[$P{imagesDir}+"logo.bmp"]]></imageExpression>
</image>