0

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)
Community
  • 1
  • 1
ybqrzml
  • 1
  • 1

1 Answers1

0

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.

Community
  • 1
  • 1
Paul Samsotha
  • 188,774
  • 31
  • 430
  • 651
  • I swapped out the Jersey 1.x for the Jersey 2.x. This didn't make the exception go away. On other posts people talk about registering the MultiPart.class either using ResourceConfg or web.xml, fabric3 doesn't seem to use either of these. I don't know how to register classes so on startup I get the exception above. Do you know how to do the register? – ybqrzml Jun 09 '15 at 13:31
  • Did you even look at the answer I linked to. I really didn't really feel like repeating myself on something that was answered for the exact same problem less then a day ago. If you still can't get it to work, let me know – Paul Samsotha Jun 09 '15 at 13:34
  • Sorry missed the part about the "not using ResourceConfig" or web.xml. Well now you have another task "how does Jersey load in fabric3". Only three ways to register a feature. The third not mentioned in the link can be seen [here](http://stackoverflow.com/a/29390508/2587435). Register it in a `Feature` and annotate the `Feature` with `@Provider`. If all your resource and providers are picked up automagically, then there is classpath scanning going on, and the feature should be picked up – Paul Samsotha Jun 09 '15 at 13:36