Search code examples
exceptionjsfuploadnulltomahawk

t:fileInputUpload null source when uploading file


I'm using tomahawk (1.1.11) and Mojarra (2.1.4) to develop a JSF app. When I upload small files (kb) it works fine, but when I upload files of about 160Mb it sends an error null source.

Here's my code so far:

    <h:form id="menuForm" enctype="multipart/form-data">
        <h:outputLabel for="option" value="Acciones disponibles: " />
        <h:selectOneMenu id="option"
                         value="#{uploadFile.option}">
            <f:selectItem itemLabel="Seleccione una opción..." itemValue="null" />
            <f:selectItems value="#{uploadFile.options}" />
            <f:ajax render="@form" execute="@form" />
        </h:selectOneMenu>

        <h:panelGrid id="dataLoad" columns ="3" 
                     rendered="#{uploadFile.option == 'Agregar información (sin validación).' ||
                                 uploadFile.option == 'Cargar información completa (con validación).' || 
                                 uploadFile.option == 'Cargar solo información errónea (con validación).'}">
            <h:outputLabel for="upfile" value="Archivo: " />
            <t:inputFileUpload id="upfile" 
                               value="#{uploadFile.upFile}" />
            <h:panelGroup/>
            <h:panelGroup/>
            <h:commandButton value="Continuar"
                             onclick="return confirmation()"
                             action="#{uploadFile.upload}" />
        </h:panelGrid>

        <h:panelGrid id="dataValidate" columns="3"
                     rendered="#{uploadFile.option == 'Validar información actual.'}">
            <h:commandButton value=" Validar " action="#{uploadFile.validate()}"/>
        </h:panelGrid>

        <h:panelGrid id="listFiles" columns="3"
                     rendered="#{uploadFile.option == 'Visualizar todos los archivos.'}">
            <t:tree2 id="tree" value="#{listFiles.treeRoot}"
                     var="node" varNodeToggler="t" 
                     clientSideToggle="false">
                <f:facet name="folder">
                    <h:panelGroup>
                        <t:graphicImage value="images/folderOpen.png"
                                        rendered="#{t.nodeExpanded}"
                                        border="0" />
                        <t:graphicImage value="images/folderClose.png"
                                        rendered="#{!t.nodeExpanded}"
                                        border="0" />
                        <h:outputText value="#{node.description}"
                                      styleClass="nodeFolder" />
                    </h:panelGroup>
                </f:facet>
                <f:facet name="file">
                    <h:panelGroup>
                        <h:commandLink immediate="true"
                                       action="#{listFiles.download(node.identifier)}">
                            <t:graphicImage value="images/file.png" border="0" />
                            <h:outputText value="#{node.description}" />
                        </h:commandLink>
                    </h:panelGroup>
                </f:facet>
            </t:tree2>
        </h:panelGrid>
    </h:form>

and actually I need to upload files larger than that, even up to 2 Gb. Any advise?

UPDATE

Here's the full stack trace

java.lang.IllegalArgumentException: null source
at java.util.EventObject.<init>(Unknown Source)
at javax.faces.event.SystemEvent.<init>(SystemEvent.java:71)
at javax.faces.event.ComponentSystemEvent.<init>(ComponentSystemEvent.java:73)
at javax.faces.event.PostRestoreStateEvent.<init>(PostRestoreStateEvent.java:73)
at com.sun.faces.lifecycle.RestoreViewPhase.deliverPostRestoreStateEvent(RestoreViewPhase.java:271)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:257)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:269)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1773)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

UPDATE

I will also put the web.xml file, maybe I'm missing some configuration.

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
        <param-value>false</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>

    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>

    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>

    <filter>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>

        <init-param>
            <param-name>uploadMaxFileSize</param-name>
            <param-value>5g</param-value>
        </init-param>
        <init-param>
            <param-name>uploadThresholdSize</param-name>
            <param-value>500m</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>

    <filter-mapping>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <servlet-name>/faces/*</servlet-name>
    </filter-mapping>
</web-app>

Solution

  • Finally ! I found the cause of the problem, but I'm no really sure what was going on, so I would like if someone can help me out with this.

    First, the problem was with the web.xml file. At the very end I had something like

    <filter-mapping>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <servlet-name>/faces/*</servlet-name>
    </filter-mapping>
    

    So I delete it from the web.xml and it upload the file without any problems! I think, the server was confused with this `filter-mapping and the servlet-mapping. I hope someone with more experience help me (and all people reading this question) clear this thing out.