java - Missing dependencies while trying to upload file with jersey -
i trying develop application upload file jersey errors on dependencies. have checked other posts did not find solution.
below error:
severe: following errors , warnings have been detected resource and/or provider classes: severe: missing dependency method public javax.ws.rs.core.response upload.server.uploadfile(java.io.inputstream,com.sun.jersey.core.header.formdatacontentdisposition) @ parameter @ index 0 severe: missing dependency method public javax.ws.rs.core.response upload.server.uploadfile(java.io.inputstream,com.sun.jersey.core.header.formdatacontentdisposition) @ parameter @ index 1 severe: method, public javax.ws.rs.core.response upload.server.uploadfile(java.io.inputstream,com.sun.jersey.core.header.formdatacontentdisposition), annotated post of resource, class upload.server, not recognized valid resource method. jun 27, 2014 12:37:16 pm org.apache.catalina.core.applicationcontext log
here code:
package upload; import java.io.file; import java.io.fileoutputstream; import java.io.ioexception; import java.io.inputstream; import java.io.outputstream; import javax.ws.rs.consumes; import javax.ws.rs.post; import javax.ws.rs.path; import javax.ws.rs.core.mediatype; import javax.ws.rs.core.response; import com.sun.jersey.core.header.formdatacontentdisposition; import com.sun.jersey.multipart.formdataparam; @path("/file") public class server { @post @path("/upload") @consumes(mediatype.multipart_form_data) public response uploadfile( @formdataparam("file") inputstream uploadedinputstream, @formdataparam("file") formdatacontentdisposition filedetail) { string uploadedfilelocation = "c://" + filedetail.getfilename(); writetofile(uploadedinputstream, uploadedfilelocation); string output = "file uploaded : " + uploadedfilelocation; return response.status(200).entity(output).build(); } private void writetofile(inputstream uploadedinputstream, string uploadedfilelocation) { try { outputstream out = new fileoutputstream(new file(uploadedfilelocation)); int read = 0; byte[] bytes = new byte[1024]; out = new fileoutputstream(new file(uploadedfilelocation)); while ((read = uploadedinputstream.read(bytes)) != -1) { out.write(bytes, 0, read); } out.flush(); out.close(); } catch (ioexception e) { e.printstacktrace(); } } }
below image of jars
any appreciated.
Comments
Post a Comment