Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-4590

NullPointerException when PrimeFaces FileUpload used in composite component

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.0, 4.0.1
    • 4.0.1
    • General
    • None
    • primefaces-test project, jakarta branch

    Description

      Using the following composite component, an exception occurs upon rendering only on MyFaces but not on Mojarra. Please let me know if this is a PrimeFaces bug instead and I'll open an issue there.

      <?xml version="1.0" encoding="UTF-8"?>
      
      <ui:component xmlns="http://www.w3.org/1999/xhtml"
                    xmlns:cc="http://xmlns.jcp.org/jsf/composite"
                    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                    xmlns:p="http://primefaces.org/ui"
                    xmlns:h="http://xmlns.jcp.org/jsf/html">
          <cc:interface>
      
              <cc:attribute name="fileUploadListener"
                            required="true"
                            method-signature="void listener(org.primefaces.event.FileUploadEvent)"/>
      
              <cc:attribute name="update"
                            type="java.lang.String"/>
      
              <cc:attribute name="allowTypes"
                            default="/.*/"/>
              <cc:attribute name="accept"/>
              <cc:attribute name="fileLimit"
                            default="1"/>
              <cc:attribute name="sizeLimit"/>
              <cc:attribute name="multiple"
                            default="false"/>
          </cc:interface>
          <cc:implementation>
              <div id="#{cc.clientId}">
                  <p:fileUpload id="fileUpload"
                                listener="#{cc.attrs.fileUploadListener}"
                                update="#{cc.attrs.update}"
                                fileLimit="#{cc.attrs.fileLimit}"
                                sizeLimit="#{cc.attrs.sizeLimit}"
                                auto="true"
                                accept="#{cc.attrs.accept}"
                                sequential="true"
                                allowTypes="#{cc.attrs.allowTypes}"
                                multiple="#{cc.attrs.multiple}"/>
              </div>
          </cc:implementation>
      </ui:component> 

      The exception:

      Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Long.longValue()" because the return value of "org.primefaces.component.fileupload.FileUpload.getSizeLimit()" is null
          at org.primefaces.component.fileupload.FileUploadRenderer.encodeScript (FileUploadRenderer.java:127)
          at org.primefaces.component.fileupload.FileUploadRenderer.encodeEnd (FileUploadRenderer.java:79)
          at jakarta.faces.component.UIComponentBase.encodeEnd (UIComponentBase.java:634) 

      You can find my reproducer here: https://github.com/mkomko/primefaces-test/tree/file-upload-npe

      Thank you very much in advance as always .

      Attachments

        Issue Links

          Activity

            People

              tandraschko Thomas Andraschko
              mkomko Manuel K
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: