NPE in StrutsUploadedFile

Tamás Barta <[email protected]> Tue, 29 Apr 2025 14:00:08 +0200
Newsgroups gmane.comp.jakarta.struts.user
Message-ID <CAM+Uwix_Zzjqx0uLg612GV_X71mj0H=4yp-6vptKbEmpTGOcUg@mail.gmail.com>
Hi!

We use Struts 6.7.4 and today we got the following exception in our
production system. I don't know how it is possible or how to reproduce it
or how to avoid it. Do you have any ideas? Of course it was a POST with
file upload.

java.lang.NullPointerException: Cannot invoke "java.io.File.length()"
because "this.file" is null
        at
deployment.deployment.ear//org.apache.struts2.dispatcher.multipart.StrutsUploadedFile.length(StrutsUploadedFile.java:52)
        at
deployment.deployment.ear//org.apache.struts2.interceptor.AbstractFileUploadInterceptor.acceptFile(AbstractFileUploadInterceptor.java:133)
        at
deployment.deployment.ear//org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:232)
        at
deployment.deployment.ear//com.opensymphony.xwork2.interceptor.AbstractInterceptor.intercept(AbstractInterceptor.java:36)
        at
deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.executeConditional(DefaultActionInvocation.java:303)
        at
deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:257)
        at
deployment.deployment.ear//com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:104)
        at
deployment.deployment.ear//com.opensymphony.xwork2.interceptor.AbstractInterceptor.intercept(AbstractInterceptor.java:36)
        at
deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.executeConditional(DefaultActionInvocation.java:303)
        at
deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:257)
        at
deployment.deployment.ear//com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:169)
        at
deployment.deployment.ear//com.opensymphony.xwork2.interceptor.AbstractInterceptor.intercept(AbstractInterceptor.java:36)
        at
deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.executeConditional(DefaultActionInvocation.java:303)
        at
deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:257)
        at
deployment.deployment.ear//org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:154)
        at
deployment.deployment.ear//com.opensymphony.xwork2.interceptor.AbstractInterceptor.intercept(AbstractInterceptor.java:36)
        at
deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.executeConditional(DefaultActionInvocation.java:303)
        at
deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:257)
        at
deployment.deployment.ear//com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:199)
        at
deployment.deployment.ear//com.opensymphony.xwork2.interceptor.AbstractInterceptor.intercept(AbstractInterceptor.java:36)
        at
deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.executeConditional(DefaultActionInvocation.java:303)
        at
deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:257)
        ...

Thanks, Tamás