title: Primefaces dynamic resource always null?
body: <p>My example look like <a href="http://www.primefaces.org/showcase/ui/dynamicImage.jsf" rel="nofollow">Dynamic Image Streaming</a> of <code>Primefaces showcase</code>. In showcase, there is no problem.<br/>
  When I try to develop like that,  dynamic resource is always <code>null</code>. <br/>
  According to my stack trace, attachment byte content cannot be <code>null</code>.<br/>
  What I need to do, configuration or something?</p>
  
  <p>ImageActionBean.java</p>
  
  <pre><code>@ManagedBean(name = "ImageActionBean")
  @SessionScoped
  public class ImageActionBean {
      private List&lt;StreamedContent&gt; attachmentList;
  
      //ManagedProperty
  
      @PostConstruct
      public void init() {
          attachmentList = new ArrayList&lt;StreamedContent&gt;();
  
          ProposalItem proposalItem = proposalItemService.findProposalItemById("PIT00000000000022122012014");
  
          for(IAttachment attachment : proposalItem.getProposalAttachmentList()) {
  
              System.out.println("Attachment : " + attachment.getName() + " : " + attachment.getData().length);
  
              attachmentList.add(new DefaultStreamedContent(new ByteArrayInputStream(attachment.getData()), attachment.getContextType()));
          }
      }
  
      public List&lt;StreamedContent&gt; getAttachmentList() {
          return attachmentList;
      }
  }
  </code></pre>
  
  <p>attachment.xhml</p>
  
  <pre><code>&lt;h:form id="attachmentForm"&gt;
      &lt;p:dataTable var="file" value="#{ImageActionBean.attachmentList}" rows="1" paginator="true"&gt;
          &lt;p:column&gt;
              &lt;p:graphicImage value="#{file}" /&gt;
          &lt;/p:column&gt;
      &lt;/p:dataTable&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>stack trace : </p>
  
  <pre><code>11:06:33,340 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) Attachment : Hydrangeas.jpg : 595284
  
  11:06:33,340 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) Attachment : Chrysanthemum.jpg : 879394
  
  11:06:33,341 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) Attachment : Desert.jpg : 845941
  
  11:06:33,341 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) Attachment : Tulips.jpg : 620888
  
  11:06:33,341 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) Attachment : Penguins.jpg : 777835
  
  11:06:33,478 SEVERE [org.primefaces.application.PrimeResourceHandler] (http-localhost-127.0.0.1-8080-1) Error in streaming dynamic resource. null
  11:06:33,478 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/tds-insu].[Faces Servlet]] (http-localhost-127.0.0.1-8080-1) Servlet.ser
  vice() for servlet Faces Servlet threw exception: java.io.IOException: java.lang.NullPointerException
      at org.primefaces.application.PrimeResourceHandler.handleResourceRequest(PrimeResourceHandler.java:109) [primefaces-4.0-20130910.075046-7.jar:4.0-SNAPSHOT]
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:591) [jboss-jsf-api_2.1_spec-2.0.5.Final.jar:2.0.5.Final]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
      at org.omnifaces.filter.FacesExceptionFilter.doFilter(FacesExceptionFilter.java:56) [omnifaces-1.7.jar:1.7]
      at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:77) [omnifaces-1.7.jar:1.7]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
      at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:98) [primefaces-4.0-20130910.075046-7.jar:4.0-SNAPSHOT]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
      at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
      at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
      at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
      at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_23]
  Caused by: java.lang.NullPointerException
      at org.primefaces.application.PrimeResourceHandler.handleResourceRequest(PrimeResourceHandler.java:83) [primefaces-4.0-20130910.075046-7.jar:4.0-SNAPSHOT]
      ... 25 more     
  </code></pre>