Uploading a document usibg fabric3

132 views Asked by At

I am trying to upload documents to our server using fabric3, I have annotated my interface method as so

@POST
@Path("/document")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile( @FormDataParam("file") InputStream uploadedInputStream,
                            @FormDataParam("file") FormDataContentDisposition fileDetail);

However when I go to deploy under fabric3 I get an exception. I saw an answer to a similar question, Jersey 2 injection source for multipart formdata) so I assume I have to do something similar. However I can't find any information about how to do this with fabric3. Does anyone have any ideas? Thanks

[[FATAL] No injection source found for a parameter of type public abstract javax
.ws.rs.core.Response com.autotec.controller.DocumentController.uploadFile(java.i
o.InputStream,com.sun.jersey.core.header.FormDataContentDisposition) at index 0.
; source='ResourceMethod{httpMethod=POST, consumedTypes=[multipart/form-data], p
roducedTypes=[text/html], suspended=false, suspendTimeout=0, suspendTimeoutUnit=
MILLISECONDS, invocable=Invocable{handler=InstanceBasedMethodHandler{handler=org
.fabric3.binding.rs.runtime.container.F3ResourceHandler@5c064de1, handlerClass=c
lass org.fabric3.binding.rs.runtime.container.F3ResourceHandler}, definitionMeth
od=public abstract javax.ws.rs.core.Response com.autotec.controller.DocumentCont
roller.uploadFile(java.io.InputStream,com.sun.jersey.core.header.FormDataContent
Disposition), parameters=[Parameter [type=class java.io.InputStream, source=file
, defaultValue=null], Parameter [type=class com.sun.jersey.core.header.FormDataC
ontentDisposition, source=file, defaultValue=null]], responseType=class javax.ws
.rs.core.Response}, nameBindings=[]}']
        at org.glassfish.jersey.server.ApplicationHandler.initialize(Application
Handler.java:467)
        at org.glassfish.jersey.server.ApplicationHandler.access$500(Application
Handler.java:163)
        at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandl
er.java:323)
        at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
        at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.processWithException(Errors.java
:286)
1

There are 1 answers

3
Paul Samsotha On

Looks like you are trying to mix Jersey 1.x multipart support with Jersey 2.x. This will not work. You're getting the error because during model validation, Jersey can't find the need provider.

See this related post for how to fix it. And in general see the Jersey 2.x documentation for Multipart support.