I am using primefaces 3. I need to display an image from database on UI. Below is the code snippet from xhtml:
<p:graphicImage value="#{entityBean.loadImage()}" title="abc" alt="Image test! "/>
<h:outputText id="output" value="Stream Contents: #{entityBean.loadImage()}" />
and the bean method to get the image contents from db is:
public org.primefaces.model.StreamedContent loadImage() {
InputStream dbStream;
dbStream = new ByteArrayInputStream(getBlobByteArray());
org.primefaces.model.StreamedContent dbImage = new org.primefaces.model.DefaultStreamedContent(dbStream,
"image/jpeg");
return dbImage.getStream().;
}
When the page is rendered i can see below output:
Image test! Stream Contents: org.primefaces.model.DefaultStreamedContent@8bc8f4
It shows that the stream contents are retrieved correctly.
I am getting below error in logs:
org.primefaces.application.PrimeResourceHandler handleResourceRequest SEVERE: Error in streaming dynamic resource.
I googled the problem there is very less help available and the available solutions didn't worked. This is not the exact code as there are some project specific code around this. Any pointer to solution or suggestion is requested.