this code i tested for values
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.TEXT_PLAIN)
public String getE(@FormDataParam("file") InputStream inputStream,@FormDataParam("file") FormDataContentDisposition fileMetaData) {
String out = "";
Map<String, String> l = fileMetaData.getParameters();
Collection<String> s = l.values();
Iterator i = s.iterator();
while(i.hasNext())
{
out += i.next()+" ";
}
return out; }
i am getting this exception
SEVERE: StandardWrapper.Throwable org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization. [[FATAL] No injection source found for a parameter of type public java.lang.String my.Service.getE(java.io.InputStream,org.glassfish.jersey.media.multipart.FormDataContentDisposition) at index 0.; source='ResourceMethod{httpMethod=POST, consumedTypes=[multipart/form-data], producedTypes=[text/plain], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class my.Service, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@4023c98]}, definitionMethod=public java.lang.String my.Service.getE(java.io.InputStream,org.glassfish.jersey.media.multipart.FormDataContentDisposition), parameters=[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 java.lang.String}, nameBindings=[]}']
Dependencies are
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>2.16</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.16</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.16</version>
</dependency>
my service class
@Path("empdata")
public class Service {
EmpService service = new EmpService();
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.TEXT_PLAIN)
public String getE(@FormDataParam("file") InputStream inputStream,@FormDataParam("file") FormDataContentDisposition fileMetaData) {
String out = "";
Map<String, String> l = fileMetaData.getParameters();
Collection<String> s = l.values();
Iterator i = s.iterator();
while(i.hasNext())
{
out += i.next()+" ";
}
return out;//
}
}
and i registered my ResourceConfig sub class
this is how i am sending request and file this is how my request header and body part looks like Thanks!