Hi, Using Struts 2.1.8 and the JasperReports plugin for Struts 2 struts2-jasperreports-plugin-2.1.8.jar.
I am trying to display an image in a PDF report. That image is stored as BLOB in the database. In struts.xml I have specified the following code: <action name="afficheFichePDF" class="com.eni.dvtejb.clientStruts2.action.JasperArticleAction"> <result name="success" type="jasper"> <param name="location">rapports\ficheArticle.jasper</param> <param name="dataSource">artDetails</param> <param name="format">PDF</param> <param name="reportParameters">paramsRapport</param> <param name="imageServletUrl">/servlets/image?image=</param> </result> </action> In my web.xml I have added the mapping for the ImageServlet servlet that is part of the JasperReports library : <servlet> <servlet-name>ImageServlet</servlet-name> <servlet-class>net.sf.jasperreports.j2ee.servlets.ImageServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>ImageServlet</servlet-name> <url-pattern>/servlets/image</url-pattern> </servlet-mapping> In my .jrxml file, produced with iReport, I have defined a field with Expression class equal to java.io.InputStream. I get the following error : Struts Problem Report Struts has detected an unhandled exception: Messages: 1. Cannot cast object 'org.apache.struts2.views.jasperreports.valuestackdatasou...@a0d16c' with class 'org.apache.struts2.views.jasperreports.ValueStackDataSource' to class 'java.io.InputStream' 2. Error evaluating expression : Source text : $F{image} 3. Error evaluating expression : Source text : $F{image} File: org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.java Line number: 340 Stacktraces javax.servlet.ServletException: Error evaluating expression : Source text : $F{image} org.apache.struts2.views.jasperreports.JasperReportsResult.doExecute(JasperReportsResult.java:331) org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186) com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:362) I tried without the image, it works. But then how exactly do you handle images with that plugin ? What is the format of the image supposed to be in the .jrxml file ? Thanks for helping.