Richfaces fileuploader nullpointer firefox

喜欢而已 提交于 2019-12-11 15:42:45

问题


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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/52742539/richfaces-fileuploader-nullpointer-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!