我有一个方法:
@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:
但我仍然得到同样的错误。