我在部署 Web 服务时遇到了一个问题。我似乎已经尝试了一切(尽管显然这不是真的)。
这些是我的球衣依赖项:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>org.jvnet</groupId>
<artifactId>mimepull</artifactId>
<version>1.6</version>
</dependency>
这是我为其中一项服务提供的代码:
@POST
@Path("/")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces("text/plain")
public String uploadFile(@FormDataParam("uploadID") String uploadID,
@FormDataParam("file") InputStream uploadedFile,
@FormDataParam("file") FormDataContentDisposition fileDetail) {
UploadServiceHandler handler = uploadHandlers.get(uploadID);
if (!isValidParameters(uploadID, uploadedFile, fileDetail, handler)
|| uploadID.length() == 0) {
log.info(uploadID + " received upload ERROR Invalid Request");
return new MessagesBean(ResponseTypes.ERROR, 1, "Invalid Request")
.toJSONString();
}
handler.init(uploadedFile, UPLOAD_PATH);
uploadHandlers.put(uploadID, handler);
log.info(uploadID + " started file upload");
handler.handleRequest();
String jsonString = handler.bean().toJSONString();
DaemonCleaner.addPath(handler.getDeletePath());
uploadHandlers.remove(handler.getUploadID());
handler.destroy();
return jsonString;
}
这是来自 Jersey 的结果堆栈跟踪
SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
WARNING: A sub-resource method, public java.lang.String org.isatools.resources.UpdateServices.update(java.lang.String), with URI template, "/", is treated as a resource method
WARNING: A sub-resource method, public java.lang.String org.isatools.resources.UploadServices.uploadFile(java.lang.String,java.io.InputStream,com.sun.jersey.core.header.FormDataContentDisposition), with URI template, "/", is treated as a resource method
SEVERE: Missing dependency for method public java.lang.String org.isatools.resources.UploadServices.postInit(java.lang.String,long) at parameter at index 0
SEVERE: Missing dependency for method public java.lang.String org.isatools.resources.UploadServices.postInit(java.lang.String,long) at parameter at index 1
SEVERE: Method, public java.lang.String org.isatools.resources.UploadServices.postInit(java.lang.String,long), annotated with POST of resource, class org.isatools.resources.UploadServices, is not recognized as valid resource method.
SEVERE: Missing dependency for method public java.lang.String org.isatools.resources.UploadServices.uploadFile(java.lang.String,java.io.InputStream,com.sun.jersey.core.header.FormDataContentDisposition) at parameter at index 0
SEVERE: Missing dependency for method public java.lang.String org.isatools.resources.UploadServices.uploadFile(java.lang.String,java.io.InputStream,com.sun.jersey.core.header.FormDataContentDisposition) at parameter at index 1
SEVERE: Missing dependency for method public java.lang.String org.isatools.resources.UploadServices.uploadFile(java.lang.String,java.io.InputStream,com.sun.jersey.core.header.FormDataContentDisposition) at parameter at index 2
SEVERE: Method, public java.lang.String org.isatools.resources.UploadServices.uploadFile(java.lang.String,java.io.InputStream,com.sun.jersey.core.header.FormDataContentDisposition), annotated with POST of resource, class org.isatools.resources.UploadServices, is not recognized as valid resource method.
提前感谢您的任何帮助!