gpt4 book ai didi

jquery - multipart/form-data 的实例化错误;客户端向服务器请求

转载 作者:行者123 更新时间:2023-12-01 00:30:25 24 4
gpt4 key购买 nike

我实现了一个用户界面和一个网络服务。通信是与rest 进行的,并且两者都在tomcat 服务器上运行。如果我想发送请求,则会收到错误:

HTTP Status 500 – Internal Server Error

javax.servlet.ServletException: Servlet execution threw an exception
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

Root Cause

java.lang.InstantiationError: org.apache.james.mime4j.message.BodyFactory
org.apache.james.mime4j.message.MessageBuilder.<init>(MessageBuilder.java:56)
org.apache.james.mime4j.message.Message.<init>(Message.java:140)
org.apache.james.mime4j.message.Message.<init>(Message.java:100)
org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl.parse(MultipartInputImpl.java:76)
org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataReader.readFrom(MultipartFormDataReader.java:52)
org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataReader.readFrom(MultipartFormDataReader.java:20)
org.jboss.resteasy.core.interception.jaxrs.AbstractReaderInterceptorContext.readFrom(AbstractReaderInterceptorContext.java:66)
org.jboss.resteasy.core.interception.jaxrs.ServerReaderInterceptorContext.readFrom(ServerReaderInterceptorContext.java:61)
org.jboss.resteasy.core.interception.jaxrs.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:56)
org.jboss.resteasy.plugins.interceptors.GZIPDecodingInterceptor.aroundReadFrom(GZIPDecodingInterceptor.java:123)
org.jboss.resteasy.core.interception.jaxrs.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:59)
org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:147)
org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:92)
org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:115)
org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:294)
org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:248)
org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:235)
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:398)
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:205)
org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:228)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

前端部分:

 function uploadFile(url, data){
console.log(url);
return $.ajax({
method: "POST",
type: 'POST',
url: url,
data: data,
cache: false,
processData: false,
contentType: false,
headers: {
"Authorization" : "Bearer " + window.sessionStorage.getItem("authToken"),
"User" : window.sessionStorage.getItem("userID")
}
})
}

后端:

    @POST
@Path("url")
@PermitAll
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public static Response uploadEvents(MultipartFormDataInput input, @Context HttpHeaders headers) throws Exception {
}

Allready 尝试在前端内容类型中设置 multipart/form-data,但也收到此错误消息。

本地配置正在运行。在网络服务器上,如果我使用该函数,它会遇到错误消息。

编辑:当我使用新的 restay 版本 3.9.0.Final 更新 POM 后,错误变为:

The server encountered an unexpected condition that prevented it from fulfilling the request.</p><p><b>Exception</b></p><pre>javax.servlet.ServletException: Servlet execution threw an exception
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
</pre><p><b>Root Cause</b></p><pre>java.lang.InstantiationError: org.apache.james.mime4j.message.BodyFactory
org.apache.james.mime4j.message.MessageBuilder.&lt;init&gt;(MessageBuilder.java:56)
org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryOnlyMessageBuilder.&lt;init&gt;(MultipartInputImpl.java:112)
org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryOnlyMessageBuilder.&lt;init&gt;(MultipartInputImpl.java:81)
org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryMessage.&lt;init&gt;(MultipartInputImpl.java:183)
org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryMessage.&lt;init&gt;(MultipartInputImpl.java:169)
org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl.parse(MultipartInputImpl.java:235)
org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataReader.readFrom(MultipartFormDataReader.java:53)
org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataReader.readFrom(MultipartFormDataReader.java:23)
org.jboss.resteasy.core.interception.jaxrs.AbstractReaderInterceptorContext.readFrom(AbstractReaderInterceptorContext.java:66)
org.jboss.resteasy.core.interception.jaxrs.ServerReaderInterceptorContext.readFrom(ServerReaderInterceptorContext.java:61)
org.jboss.resteasy.core.interception.jaxrs.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:56)
org.jboss.resteasy.plugins.interceptors.GZIPDecodingInterceptor.aroundReadFrom(GZIPDecodingInterceptor.java:123)
org.jboss.resteasy.core.interception.jaxrs.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:59)
org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:147)
org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:92)
org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:115)
org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:294)
org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:248)
org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:235)
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:398)
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:205)
org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:228)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
</pre><p><b>Note</b> The full stack trace of the root cause is available in the server logs.</p><hr class="line" /><h3>Apache Tomcat/8.5.45</h3></body></html>

最佳答案

我的war文件有2个不同版本的标识jar文件。我不得不删除较新的版本。

关于jquery - multipart/form-data 的实例化错误;客户端向服务器请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57786640/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com