javajasper-reports

How to display in Jasper BLOB Image?


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'

Solution

  • 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