Reputation: 545
I'm trying to add a image to my jasperReport, but it doensnt work, it stops when it calls to:
JasperRunManager.runReportToPdf ....
I have images in Database as type BLOB, and in the "file.jrxml" i have set it as
field --> IMAGE_FILE
FIELDCLASS --> oracle.sql.blob.
And Image Properties:
image expresion -> $F{IMAGE_FILE}.getBinaryStream()
expression class -> java.lang.String
Message Error:
12:22:24,863 INFO [STDOUT] 12:22:24,862 ERROR [JRFillSubreport] Fill 1: exception
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : $F{IMAGE_FILE}.getBinaryStream()
...
...
Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'oracle.sql.BLOB@5d17f1ea' with class 'oracle.sql.BLOB' to class 'oracle.sql.BLOB'
at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:360)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:599)
...
...
12:22:24,863 ERROR [STDERR] net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : $F{IMAGE_FILE}.getBinaryStream()
So main errors cant solve ,and cant find reason:
12:22:24,868 ERROR [STDERR] Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : $F{IMAGE_FILE}.getBinaryStream()
12:22:24,869 ERROR [STDERR] Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'oracle.sql.BLOB@5d17f1ea' with class 'oracle.sql.BLOB' to class 'oracle.sql.BLOB'
Upvotes: 1
Views: 5786
Reputation: 91
I found this solution https://clients.maxapex.com/index.php?rp=/knowledgebase/26/Display-ImageorBLOB-in-Jasper-Reports.html and it worked for me:
<field name="IMAGE_FILE" class="java.awt.Image">
....
<imageExpression><![CDATA[$F{IMAGE_FILE}]]></imageExpression>
Upvotes: 0
Reputation: 1
Propiedades de fiel:
Propiedades de imagen:
*image expresion : $F{IMAGE_FILE} *expression class : java.lang.String
Upvotes: -1
Reputation: 545
I find the answer. Just modify this 2 values and now works:
* field : IMAGE_FILE
* field Class : oracle.sql.inputStream
And new image Properties:
*image expresion : $F{IMAGE_FILE}
*expression class : java.lang.String
Upvotes: 2