title: Error in streaming dynamic resource. Using p:graphicImage with Primefaces
body: <p>I'm trying to dynamically display an image in primefaces using the p:graphicImage tag as follows:</p>
  
  <pre><code>&lt;p:graphicImage value="#{submissionBean.contestImage}"&gt;
      &lt;f:param name="imageName"
          value="#{contestBean.createContest.submissions[0].fileName}" /&gt;
  &lt;/p:graphicImage&gt;`
  </code></pre>
  
  <p>The managed bean is as follows:</p>
  
  <pre><code>@ManagedProperty("#{param.imageName}")
  private String imageName;
  
  public String getImageName()
  {
      return imageName;
  }
  
  public void setImageName(String imageName)
  {
      this.imageName = imageName;
  }
  
  private StreamedContent contestImage;
  
  public StreamedContent getContestImage()
  {
      FacesContext context = FacesContext.getCurrentInstance();
      if (imageName == null)
          imageName = Constants.SUBMISSION_FILE_DIR + "/" + "sacxzx_asdsdaas_icon.png";
      if (context.getRenderResponse())
      {
          // So, we're rendering the view. Return a stub StreamedContent so
          // that it will generate right URL.
          return new DefaultStreamedContent();
      }
      else
      {
  
          return new DefaultStreamedContent(this.getClass().getResourceAsStream(Constants.SUBMISSION_FILE_DIR + "/" + imageName));
      }
  }
  </code></pre>
  
  <p>I'm always getting the error of "SEVERE: Error in streaming dynamic resource."</p>
  
  <p>Checking the URL for the image seems just fine:</p>
  
  <pre><code>http://localhost:8080/mashup/javax.faces.resource/dynamiccontent.xhtml?ln=primefaces&amp;pfdrid=pfdrid_4290aa0c-8eef-45ea-a281-638e460e33bf&amp;imageName=sacxzx_asdsdaas_icon.png
  </code></pre>
  
  <p>Any idea why this is?</p>
  
  <p>Thanks!</p>