0

With the introduction of Firefox 62 my existing RichFaces fileuploader is suddenly throwing null pointers upon trying to decode the uploaded file. This is using Richfaces 3.3.3 on a JBoss 5.1 environment. I've tried uploading different image types to no avail. It's also to be noted that this issue only occurs on Firefox 62 and later all other browsers are working fine.

Stacktrace:

Caused by: java.lang.NullPointerException
at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRendererBase.java:139)
at org.ajax4jsf.renderkit.RendererBase.decode(RendererBase.java:75)
at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:789)
at javax.faces.component.UIInput.decode(UIInput.java:725)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1031)
at javax.faces.component.UIInput.processDecodes(UIInput.java:639)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
at javax.faces.component.UIForm.processDecodes(UIForm.java:209)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
at javax.faces.component.UIInput.processDecodes(UIInput.java:639)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
at org.ajax4jsf.component.AjaxViewRoot$1.invokeContextCallback(AjaxViewRoot.java:400)
at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:240)
at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:417)
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)

Fileuploader xhtml:

<rich:fileUpload fileUploadListener="#{manageAttachmentContentItemAction.listener}"
maxFilesQuantity="1" 
id="upload" immediateUpload="true"
uploadControlLabel="#{messagesAction.getMessage('manage.content.item.action.upload.add_label')}" addControlLabel="#{messagesAction.getMessage('manage.content.item.action.upload.add_label')}"
progressLabel="#{messagesAction.getMessage('manage.content.item.action.upload.progress_label')}" 
disabled="#{manageAttachmentContentItemAction.previewItem != null}" 
listHeight="60px" listWidth="350px"
allowFlash="false" required="true" noDuplicate="true">
<a4j:support  event="onuploadcomplete" reRender="image_preview,uploadFunction" />
<a4j:support  event="onerror" action="#{manageAttachmentContentItemAction.onErrorOccurred}" reRender="uploadFunction" />
<a4j:support  event="ontyperejected" action="#{manageAttachmentContentItemAction.onTypeRejected}" reRender="uploadFunction" />
<a4j:support  event="onsizerejected" action="#{manageAttachmentContentItemAction.onFileSizeRejected}" reRender="uploadFunction"  />

Any hints would be greatly appreciated

Sarrox
  • 1
  • Possible duplicate of [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – Leviand Oct 10 '18 at 14:40
  • I don't think the NPE link is really relevant in this scenario, Sarrox only thing I can think of is can you obtain the source for for rich faces 3.3.3 and see if you can set a break point near this line `at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRendererBase.java:139)`. I wonder if this might be related though looks like you're not using flash [bug id 1462979](https://bugzilla.mozilla.org/show_bug.cgi?id=1462979). I'm not sure at which stage it tries to decode the file but are you able to check whether the file is being saved and decode is just failing? – JGlass Oct 10 '18 at 17:15
  • The line numbers don't match [richfaces-3.3 FileUploadRendererBase.java](https://github.com/nuxeo/richfaces-3.3/blob/master/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java) - but really looks like it's not being saved to the file system, possibly this lines causing it `List fileList = multipartRequest.getUploadItems();` – JGlass Oct 10 '18 at 17:37
  • You are correct in assuming that files are still being saved prior to being decoded. The main nuisance im left with is that the scenario is still handled as if the upload failed and a generic org.jboss.seam.UnknownException is being displayed within the user agent. Interestingly enough a different stacktrace is being produced when i set `allowFlash` to true. `org.jboss.seam.ui.UnauthorizedCommandException: viewId: /page/news/manageNewsItem.xhtml - No client identifier provided` – Sarrox Oct 11 '18 at 08:09
  • ive also tried debugging the richfaces source as per your suggestion but can't find any obvious discrepancies between a firefox upload and a working upload from another user agent. – Sarrox Oct 11 '18 at 08:17
  • I'm having the same issue with later version firefox (not older version or other browsers), I've that issue in a conversation and when I'm going to the precedent page then to that upload page, the file is there. Was anybody able to fix this? Where should I look ? – prignony Nov 22 '18 at 19:23

2 Answers2

1

You can works with NPE something like this.

1) Override the FileUploadRenderer

public class CustomFileUploadRenderer extends FileUploadRenderer {

@Override
protected void doDecode(FacesContext context, UIComponent component) {
    try {
        super.doDecode(context, component);
    } catch (NullPointerException e) {
        LOGGER.info("double decode error ignored", e);
    }
}

2) add custom class to the faces-config.xml

    <render-kit>
     <renderer>
          <component-family>org.richfaces.component.FileUpload</component-family>
          <renderer-type>org.richfaces.renderkit.html.FileUploadRenderer</renderer-type>
          <renderer-class>com.nnn.web.jsf.component.CustomFileUploadRenderer</renderer-class>
     </renderer>
</render-kit>

It works for me.

P/s I`m not sure, but this problem going from the issue https://bugzilla.mozilla.org/show_bug.cgi?id=583351

0

There is a work around to this problem, we can surround the code throwing this exception by try/catch and things will work fine. I have already tried this and it's working fine.

Zoe
  • 27,060
  • 21
  • 118
  • 148