org.apache.tomcat.util.http.fileupload.servlet.ServletRequestContext无法强制转换为org.apache.tomcat.util.http.fileupload.UploadContext

时间:2014-09-04 16:11:19

标签: ajax jsf tomcat cdi multipartform-data

我有JSF / CDI应用程序,可以在我的本地Windows环境中正常运行。 我有一个enctype形式为“multipart / form-data”的表单。在这种形式下,我使用h:inputfile上传文件。 此表单中还有其他日历和文本字段。 当我将此应用程序移动到LINUX中的IST环境时,我在尝试执行表单的ajax提交时遇到异常。我有2个ajax提交,一个涉及文件上传,另一个涉及另一个文本字段。两者都抛出下面的ClassCastException。我正在使用部署在tomcat 7中的JSF 2.2.5,Servlet 3,CDI bean。

java.lang.ClassCastException: org.apache.tomcat.util.http.fileupload.servlet.ServletRequestContext cannot be cast to org.apache.tomcat.util.http.fileupload.UploadContext
        at org.apache.tomcat.util.http.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:811) ~[tomcat-coyote.jar:7.0.33]
        at org.apache.tomcat.util.http.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:259) ~[tomcat-coyote.jar:7.0.33]
        at org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:283) ~[tomcat-coyote.jar:7.0.33]
        at org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:129) ~[tomcat-coyote.jar:7.0.33]
        at org.apache.catalina.connector.Request.parseParts(Request.java:2722) ~[catalina.jar:7.0.33]
        at org.apache.catalina.connector.Request.parseParameters(Request.java:3043) ~[catalina.jar:7.0.33]
        at org.apache.catalina.connector.Request.getParameter(Request.java:1148) ~[catalina.jar:7.0.33]
        at org.jboss.weld.servlet.ConversationContextActivator.getConversationId(ConversationContextActivator.java:124) ~[weld-servlet-2.1.0.Final.jar:2013-10-11 10:25]
        at org.jboss.weld.servlet.ConversationContextActivator.activateConversationContext(ConversationContextActivator.java:91) ~[weld-servlet-2.1.0.Final.jar:2013-10-11 10:25]
        at org.jboss.weld.servlet.HttpContextLifecycle.requestInitialized(HttpContextLifecycle.java:183) ~[weld-servlet-2.1.0.Final.jar:2013-10-11 10:25]
        at org.jboss.weld.servlet.WeldInitialListener.requestInitialized(WeldInitialListener.java:135) ~[weld-servlet-2.1.0.Final.jar:2013-10-11 10:25]
        at org.jboss.weld.servlet.api.helpers.ForwardingServletListener.requestInitialized(ForwardingServletListener.java:42) ~[weld-servlet-2.1.0.Final.jar:2013-10-11 10:25]
        at org.apache.catalina.core.StandardContext.fireRequestInitEvent(StandardContext.java:5948) ~[catalina.jar:7.0.33]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:167) [catalina.jar:7.0.33]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) [catalina.jar:7.0.33]
        at org.apache.catalina.valves.StuckThreadDetectionValve.invoke(StuckThreadDetectionValve.java:193) [catalina.jar:7.0.33]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) [catalina.jar:7.0.33]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) [catalina.jar:7.0.33]
        at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:197) [tomcat-coyote.jar:7.0.33]
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) [tomcat-coyote.jar:7.0.33]
        at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1822) [tomcat-coyote.jar:7.0.33]

非常感谢任何帮助。

更新:

我检查了我们的IST服务器,发现tomcat-coyote.jar在我的本地和IST服务器上有所不同。经过一些跟进后,我发现我们的系统管理员更新了tomcat-coyote.jar,以解决apache文件上传的一些安全问题。现在在我的本地做同样的补丁之后,我在本地也遇到了同样的错误。但有人可以告诉我如何避免这种例外。如何将org.apache.tomcat.util.http.fileupload.servlet.ServletRequestContext转换为org.apache.tomcat.util.http.fileupload.UploadContext?因为我只是在我的jsf页面中使用h:inputfile,其形式为enpartype为multipart / form-data。

0 个答案:

没有答案