我正在使用紧身衣和邮递员。通过邮递员将文本文件作为上载文件发送到我的Web服务方法时,出现以下错误。
SEVERE: Allocate exception for servlet [Jersey Web Application]
org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] No injection source found for a parameter of type public javax.ws.rs.core.Response
webservice method in short:
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response method(
@FormDataParam("file") InputStream uploadedInputStream
,@FormDataParam("file") FormDataContentDisposition fileDetail
)
我正在使用jersy org.glassfish.jersey 2.22.1
请问您在这里建议什么解决方案,以及到底需要哪个相关文件版本。
例外情况: HTTP状态500 –内部服务器错误
类型异常报告
用于Servlet [Jersey Web应用程序]的消息Servlet.init()抛出异常
说明服务器遇到意外状况,阻止其满足请求。
例外
javax.servlet.ServletException:Servlet [Jersey Web应用程序]的Servlet.init()引发异常 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:770) org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1415) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源) java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知源) org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(未知源) 根本原因
org.glassfish.jersey.server.model.ModelValidationException:在应用程序初始化期间,对应用程序资源模型的验证失败。 [[FATAL]找不到类型为public javax.ws.rs.core.Response uploadFile(java.io.InputStream,org.glassfish.jersey.media.multipart.FormDataContentDisposition)的参数的注入源,引发java.lang.Exception索引0。源=“ ResourceMethod {httpMethod = POST,consumedTypes = [multipart / form-data],producedTypes = [],suspended = false,suspendTimeout = 0,suspendedTimeoutUnit = MILLISECONDS,invocable = Invocable {handler = MethodHandler {handlerClass = class Resource,handlerConstructors = [org.glassfish.jersey.server.model.HandlerConstructor@2dc2b33b]},handlingMethod = public javax.ws.rs.core.Response uploadFile(java.io.InputStream,org.glassfish.jersey.media.multipart.FormDataContentDisposition)引发java.lang.Exception,参数= [参数[type = class java.io.InputStream,源=文件,defaultValue =空],参数[type = class org.glassfish.jersey.media.multipart.FormDataContentDisposition,源=文件,defaultValue = null]],responseType = class javax.ws.rs.core.Response},nameBindings = []}'] org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:426) org.glassfish.jersey.server.ApplicationHandler.access $ 500(ApplicationHandler.java:161) org.glassfish.jersey.server.ApplicationHandler $ 3.run(ApplicationHandler.java:286) org.glassfish.jersey.internal.Errors $ 2.call(Errors.java:289) org.glassfish.jersey.internal.Errors $ 2.call(Errors.java:286) org.glassfish.jersey.internal.Errors.process(Errors.java:315) org.glassfish.jersey.internal.Errors.process(Errors.java:297) org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286) org.glassfish.jersey.server.ApplicationHandler。(ApplicationHandler.java:283) org.glassfish.jersey.servlet.WebComponent。(WebComponent.java:298) org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167) org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349) javax.servlet.GenericServlet.init(GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:770) org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1415) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源) java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知源) org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(未知源) 注意服务器日志中提供了根本原因的完整堆栈跟踪。