我有一个方法:
@POST
@Consumes("multipart/form-data")
@Produces( {"text/xml"})
public Response processForm(
@FormDataParam("myparam") InputStream is,
@FormDataParam("myparam") FormDataContentDisposition detail)
这在Jersey 1.x中效果良好。
我正在升级到2.0 m11版本。
现在我遇到了以下错误:
12/01/2013 11:15:04 AM org.glassfish.jersey.server.ApplicationHandler initialize
INFO: Initiating Jersey application, version Jersey: 2.0-m11 2012-12-21 12:34:15...
12/01/2013 11:15:04 AM org.glassfish.jersey.internal.Errors processErrors
SEVERE: The following errors and warnings have been detected:
WARNING: No injection source found for a parameter of type public javax.ws.rs.core.Response com.plutext.FileUpload.processForm(java.io.InputStream,org.glassfish
.jersey.media.multipart.FormDataContentDisposition) at index 0.
我找到了http://java.net/jira/browse/JERSEY-1413和提交的http://java.net/projects/jersey/lists/commits/archive/2012-09/message/126,这些似乎是相关的,但我不确定该如何修复问题。
更新:
我创建了一个Servlet,在org.glassfish.jersey.server.ApplicationHandler初始化之前在Tomcat中运行:
public class Jersey2Init extends HttpServlet {
private static final Logger jul = Logger.getLogger(Jersey2Init.class
.getName());
static {
System.out.println("\n\nrunning Jersey2Init\n\n");
final ResourceConfig resourceConfig1 = new ResourceConfig(XFormService.class);
resourceConfig1.registerInstances(new LoggingFilter(jul, true));
resourceConfig1.register(MultiPartFeature.class);
final ResourceConfig resourceConfig2 = new ResourceConfig(AssembleService.class);
resourceConfig2.registerInstances(new LoggingFilter(jul, true));
resourceConfig2.register(MultiPartFeature.class);
}
}
它绝对是第一次运行:
INFO: Deploying web application archive C:\Java\apache-tomcat-7.0.29\webapps\Foo-Services.war
running Jersey2Init
18/01/2013 9:09:51 PM org.glassfish.jersey.server.ApplicationHandler initialize
INFO: Initiating Jersey application, version Jersey: 2.0-m11 2012-12-21 12:34:15...
18/01/2013 9:09:52 PM org.glassfish.jersey.internal.Errors processErrors
SEVERE: The following errors and warnings have been detected:
但我仍然得到相同的错误。