Tom O'Brien Tom O'Brien - 2 months ago 30
reST (reStructuredText) Question

MULTIPART_FORM_DATA: No injection source found for a parameter of type Response

I'm trying to get a file upload working for JAX-RS using multipart/form-data. When I try to start the server it gives me this error:

[[FATAL] No injection source found for a parameter of type public javax.ws.rs.core.Response
com.pododdle.resources.UploadResource.uploadAudio(int,int,java.io.InputStream,org.glassfish.jersey.media.multipart.FormDataContentDisposition)
at index 2.;source='ResourceMethod{httpMethod=POST, consumedTypes=[multipart/form-data], producedTypes=[text/html], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class
com.pododdle.resources.UploadResource, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@29d4c93f]}, definitionMethod=public javax.ws.rs.core.Response
com.pododdle.resources.UploadResource.uploadAudio(int,int,java.io.InputStream,org.glassfish.jersey.media.multipart.FormDataContentDisposition), parameters=[Parameter [type=int, source=auction_id, defaultValue=null], Parameter [type=int, source=category_id, defaultValue=null], Parameter [type=class java.io.InputStream, source=file, defaultValue=null], Parameter [type=class org.glassfish.jersey.media.multipart.FormDataContentDisposition, source=file, defaultValue=null]], responseType=class javax.ws.rs.core.Response}, nameBindings=[]}']


My pom.xml looks like this:

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>${jersey.version}</version>
</dependency>

<dependency>
<groupId>org.jvnet.mimepull</groupId>
<artifactId>mimepull</artifactId>
<version>1.9.6</version>
</dependency>

</dependencies>
<properties>
<jersey.version>2.22.1</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>


The version of the mimepull that works with version 2.22.1 of jersey i get from from here: https://www.versioneye.com/java/org.glassfish.jersey.media:jersey-media-multipart/2.22.1

Is there something I am missing, or haven't configured properly? Am a novice at this, so go easy on me... :)

Answer

Once you don't have a ResourceConfig, try registering the MultiparFeature in the web.xml deployment descriptor:

<init-param>
    <param-name>jersey.config.server.provider.classnames</param-name>
    <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
</init-param>

If you have more provider class names in the <param-value>, use , to separate them.

Comments