struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maurizio Cucchiara <maurizio.cucchi...@gmail.com>
Subject Re: [S2] Struts doesn't upload 0 byte files?
Date Tue, 18 Jan 2011 21:39:33 GMT
Looking at the stacktrace you reported, it is obvious that's a java thing:
  at java.io.FileInputStream.open(Native Method)
  at java.io.FileInputStream.<init>(FileInputStream.java:137)



2011/1/18 Paul Benedict <pbenedict@apache.org>:
> Burton,
>
> I don't know if this is an issue with Struts or the servlet container. I
> suppose a 0 file upload should be allowed, or is it considered an aborted
> stream? I don't know. It's an interesting question.
>
> Paul
>
> On Tue, Jan 18, 2011 at 3:33 PM, Burton Rhodes <burtonrhodes@gmail.com>wrote:
>
>> Paul & Maurizio -
>>
>> Point taken.  I know it's a rare case, but I do feel like an empty
>> file should be treated as fairly as a a non-empty file.  If a user
>> wants to do that, I think they should be allowed.  Otherwise, avoiding
>> the exception can be solved with a bit more work on my part - I just
>> think telling the user that the file doesn't contain any data is not
>> mine to worry about.
>>
>> I included a debug log file if anyone cares.
>>
>> On Tue, Jan 18, 2011 at 3:21 PM, Maurizio Cucchiara
>> <maurizio.cucchiara@gmail.com> wrote:
>> > Do you want allow empty files or avoid exception stuff?
>> >
>> > 2011/1/18 Burton Rhodes <burtonrhodes@gmail.com>:
>> >> Bump.
>> >>
>> >> Has anyone tried to upload an empty file using Struts2/Apache/Tomcat
>> >> configuration - e.g. test.txt with 0 bytes?  I have stepped through
>> >> the FileUploadInterceptor Class and cannot locate why an empty file is
>> >> not uploaded to the "work" directory.  When I upload a file that is 1+
>> >> bytes in size, everything works fine.  This is true for both my Jetty
>> >> development enivronment & Tomcat testing server.  A 0 byte file is
not
>> >> NULL, so I wondering why there is an issue.  Anyone experienced this
>> >> or would you be able to test on one of your applications to know if
>> >> I'm crazy or not?  Or is this entirely unrelated to Struts?
>> >>
>> >> Any thoughts are appreciated.
>> >>
>> >> On Mon, Jan 17, 2011 at 5:46 PM, Burton Rhodes <burtonrhodes@gmail.com>
>> wrote:
>> >>> For some reason when a user uploades a file to my Struts application
>> >>> that has a size of "0 bytes", the file is not copied to the work
>> >>> directory of my tomcat server.  Is this a bug or a feature?  Below
is
>> >>> a stacktrace of when I tried to upload "test2.txt" with no data (0
>> >>> bytes).  Shouldn't Struts copy the file regardless of the size?  Or
is
>> >>> this not related to struts?  Thanks!
>> >>>
>> >>> FATAL: Error uploading transaction attachment.
>> >>> java.io.FileNotFoundException:
>> >>>
>> /var/lib/tomcat6/work/Catalina/localhost/afs/upload__31e58b4_12d9656546d__8000_00000017.tmp
>> >>> (No such file or directory)
>> >>>        at java.io.FileInputStream.open(Native Method)
>> >>>        at java.io.FileInputStream.<init>(FileInputStream.java:137)
>> >>>        at com.afs.util.MyFileUtil.copyFile(MyFileUtil.java:37)
>> >>>        at
>> com.afs.web.action.xaction.XactionAttachmentUploadAction.addFileToXaction(XactionAttachmentUploadAction.java:208)
>> >>>        at
>> com.afs.web.action.xaction.XactionAttachmentUploadAction.upload(XactionAttachmentUploadAction.java:156)
>> >>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> >>>        at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> >>>        at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> >>>        at java.lang.reflect.Method.invoke(Method.java:616)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
>> >>>        at
>> org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:314)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> com.afs.web.interceptor.SessionInterceptor.intercept(SessionInterceptor.java:57)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> com.afs.web.interceptor.NoCacheInterceptor.intercept(NoCacheInterceptor.java:31)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:314)
>> >>>        at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
>> >>>        at
>> org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
>> >>>        at
>> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
>> >>>        at
>> org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
>> >>>        at
>> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
>> >>>        at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>> >>>        at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>> >>>        at
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)
>> >>>        at
>> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
>> >>>        at
>> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
>> >>>        at
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
>> >>>        at
>> org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
>> >>>        at
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
>> >>>        at
>> org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
>> >>>        at
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
>> >>>        at
>> org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
>> >>>        at
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
>> >>>        at
>> org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:119)
>> >>>        at
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
>> >>>        at
>> org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
>> >>>        at
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
>> >>>        at
>> org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
>> >>>        at
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
>> >>>        at
>> org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
>> >>>        at
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
>> >>>        at
>> org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
>> >>>        at
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
>> >>>        at
>> org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
>> >>>        at
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
>> >>>        at
>> org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:109)
>> >>>        at
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
>> >>>        at
>> org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)
>> >>>        at
>> org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
>> >>>        at
>> org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
>> >>>        at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>> >>>        at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>> >>>        at
>> org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
>> >>>        at
>> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
>> >>>        at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>> >>>        at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>> >>>        at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>> >>>        at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>> >>>        at
>> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:465)
>> >>>        at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>> >>>        at
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>> >>>        at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>> >>>        at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
>> >>>        at
>> org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
>> >>>        at
>> org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
>> >>>        at
>> org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:769)
>> >>>        at
>> org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:698)
>> >>>        at
>> org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:891)
>> >>>        at
>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
>> >>>        at java.lang.Thread.run(Thread.java:636)
>> >>>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> For additional commands, e-mail: user-help@struts.apache.org
>> >>
>> >>
>> >
>> >
>> >
>> > --
>> > Maurizio Cucchiara
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>



-- 
Maurizio Cucchiara

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message