Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Re: [s2] File Upload Problem with large Files in struts2

avajon

2007-01-30

Replies:


hi,

i think it is a bug in the FilterDispatcher. I change the Method
prepareDispatcherAndWrapRequest to this and now it works. Should i post it
to a bug-report? is there such a thing?

best regards
avajon

<pre>
protected HttpServletRequest
prepareDispatcherAndWrapRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException {

    Dispatcher du = Dispatcher.getInstance();

    // Prepare and wrap the request if the cleanup filter hasn't
already, cleanup filter should be
    // configured first before struts2 dispatcher filter, hence when its
cleanup filter's turn,
    // static instance of Dispatcher should be null.
    if (du == null) {

       Dispatcher.setInstance(dispatcher);
    }
    else {
       dispatcher = du;
    }
       // prepare the request no matter what - this ensures that the
proper character encoding
       // is used before invoking the mapper (see WW-9127)
       dispatcher.prepare(request, response);

       try {
          // Wrap request first, just in case it is
multipart/form-data
          // parameters might not be accessible through before
encoding (ww-1278)
          request = dispatcher.wrapRequest(request,
getServletContext());
       } catch (IOException e) {
          String message = "Could not wrap servlet request with
MultipartRequestWrapper!";
          LOG.error(message, e);
          throw new ServletException(message, e);
       }
   
   
    return request;
  }
</pre>

avajon wrote:
>
> Hi,
>
> i have a Problem with uploading large Files in IE (Firefox it is ok).
> Here is the first part of my fileuploadinterceptor. (i just override the
> fileuploadinterceptor and added some debug messages)
>
> <pre>
> public String intercept(ActionInvocation invocation) throws Exception {
>
>    ActionContext ac = invocation.getInvocationContext();
>      HttpServletRequest request = (HttpServletRequest)
> ac.get(ServletActionContext.HTTP_REQUEST);
>      
> log.debug(ServletActionContext.getRequest()+" request: "+request);
> String content_type = request.getContentType();
> log.debug("contenttype: "+content_type+":
> "+content_type.indexOf("multipart/form-data"));
>
>      if (!(request instanceof MultiPartRequestWrapper) ) {
>         if (log.isDebugEnabled()) {
>           ActionProxy proxy = invocation.getProxy();
>           log.debug(getTextMessage("struts.messages.bypass.request",
> new Object[]{proxy.getNamespace(), proxy.getActionName()},
> ActionContext.getContext().getLocale()));
>         }
>
>       // return invocation.invoke();
>      }
>
>      final Object action = invocation.getAction();
>      ValidationAware validation = null;
>
>      if (action instanceof ValidationAware) {
>         validation = (ValidationAware) action;
>      }
>
>      MultiPartRequestWrapper multiWrapper = (MultiPartRequestWrapper)
> request;
> </pre>
>
> When i try to upload a file in IE i get (sometimes) this error:
> <pre>
> 21:55:48,430 MyFileUploadInterceptor.java -
> org.apache.catalina.connector.RequestFacade@(protected):
> org.apache.catalina.connector.RequestFacade@(protected)
> 21:55:48,431 MyFileUploadInterceptor.java - struts.valueStack=
> 21:55:48,433 MyFileUploadInterceptor.java - contenttype:
> multipart/form-data; boundary=---------------------------7d737a106042c: 0
> 21:55:48,508 MyFileUploadInterceptor.java - Ãberspringe /video/
> videoBackendUploadDone
> ERROR (Dispatcher.java:513) - Could not execute action
> java.lang.ClassCastException: org.apache.catalina.connector.RequestFacade
>      at
> com.webfreetv.interceptor.MyFileUploadInterceptor.intercept(MyFileUploadInterceptor.java:223)
>      at
> com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
>      at
> com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
>      at
> com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile (UtilTimerStack.java:455)
>      at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke (DefaultActionInvocation.java:216)
>      at
> org.apache.struts2.impl.StrutsActionProxy$1.call(StrutsActionProxy.java:46)
>      at
> org.apache.struts2.impl.StrutsActionProxy$1.call(StrutsActionProxy.java:45)
>      at
> org.apache.struts2.impl.RequestContextImpl.callInContext(RequestContextImpl.java:172)
>      at
> org.apache.struts2.impl.StrutsActionProxy.execute (StrutsActionProxy.java:44)
>      at
> org.apache.struts2.dispatcher.Dispatcher.serviceAction (Dispatcher.java:502)
>      at
> org.apache.struts2.dispatcher.FilterDispatcher.doFilter (FilterDispatcher.java:423)
>      at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:202)
>      at
> org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:173)
>      at
> org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperValve.java:213)
>      at
> org.apache.catalina.core.StandardContextValve.invoke (StandardContextValve.java:178)
>      at
> org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:126)
>      at
> org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
>      at
> org.apache.catalina.core.StandardEngineValve.invoke (StandardEngineValve.java:107)
>      at
> org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:148)
>      at
> org.apache.coyote.http11.Http11Processor.process (Http11Processor.java:869)
>      at
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
>      at
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket (PoolTcpEndpoint.java:527)
>      at
> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt (LeaderFollowerWorkerThread.java:80)
>      at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
>      at java.lang.Thread.run (Thread.java:595)
> </pre>
>
> Does anybody know what happens here?
>
> thanks
> avajon
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.