java - File upload services using jersey in tomcat without maven -
i want upload images server using restful jersey web services.i have included jersey-multipart-1.9.jar,jersey-bundle-1.14.jar , asm-3.3.1.jar jar files , i not using maven.
below code snippet upload function.
@post @path("/uploadimage") @consumes(mediatype.multipart_form_data) public response uploadfile(@formdataparam("file") inputstream fileinputstream, @formdataparam("file") formdatacontentdisposition contentdispositionheader) { string filepath = server_upload_location_folder + contentdispositionheader.getfilename(); savefile(fileinputstream, filepath);//method save file. string output = "file saved server location : " + filepath; return response.status(200).entity(output).build(); }
but getting following error when deploy or run in apache tomcat 7.
severe: missing dependency method public javax.ws.rs.core.response com.sec.samsung.fileupload.uploadfile(java.io.inputstream,com.sun.jersey.core.header.formdatacontentdisposition) @ parameter @ index 0 severe: missing dependency method public javax.ws.rs.core.response com.sec.samsung.fileupload.uploadfile(java.io.inputstream,com.sun.jersey.core.header.formdatacontentdisposition) @ parameter @ index 1 severe: method, public javax.ws.rs.core.response com.sec.samsung.fileupload.uploadfile(java.io.inputstream,com.sun.jersey.core.header.formdatacontentdisposition), annotated post of resource, class com.sec.samsung.fileupload, not recognized valid resource method. severe: servlet /uploadimage threw load() exception com.sun.jersey.spi.inject.errors$errormessagesexception @ com.sun.jersey.spi.inject.errors.processerrormessages(errors.java:170) @ com.sun.jersey.spi.inject.errors.postprocess(errors.java:136) @ com.sun.jersey.spi.inject.errors.processwitherrors(errors.java:199) @ com.sun.jersey.server.impl.application.webapplicationimpl.initiate(webapplicationimpl.java:765) @ com.sun.jersey.server.impl.application.webapplicationimpl.initiate(webapplicationimpl.java:760) @ com.sun.jersey.spi.container.servlet.servletcontainer.initiate(servletcontainer.java:489) @ com.sun.jersey.spi.container.servlet.servletcontainer$internalwebcomponent.initiate(servletcontainer.java:319) @ com.sun.jersey.spi.container.servlet.webcomponent.load(webcomponent.java:609) @ com.sun.jersey.spi.container.servlet.webcomponent.init(webcomponent.java:210) @ com.sun.jersey.spi.container.servlet.servletcontainer.init(servletcontainer.java:374) @ com.sun.jersey.spi.container.servlet.servletcontainer.init(servletcontainer.java:557) @ javax.servlet.genericservlet.init(genericservlet.java:158) @ org.apache.catalina.core.standardwrapper.initservlet(standardwrapper.java:1284) @ org.apache.catalina.core.standardwrapper.loadservlet(standardwrapper.java:1197) @ org.apache.catalina.core.standardwrapper.load(standardwrapper.java:1087) @ org.apache.catalina.core.standardcontext.loadonstartup(standardcontext.java:5210) @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5493) @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150) @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1559) @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1549) @ java.util.concurrent.futuretask$sync.innerrun(unknown source) @ java.util.concurrent.futuretask.run(unknown source) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ java.lang.thread.run(unknown source)
can me without maven support? many people have asked same question solution available using maven, not working on maven project.
i tried similar code
//code @post @path("/uploadimage") @consumes(mediatype.multipart_form_data) public response uploadfile(@formdataparam("file") inputstream uploadedstream, @formdataparam("file") formdatacontentdisposition filedetail) { string filename = filedetail.getfilename(); savetofile(uploadedstream,filename); string output = "file saved server location : " + filename; return response.status(200).entity(output).build(); }
with bellow jar files in (tomcat 7) & working fine
jersey-multipart-1.18.1.jar mimepull-1.9.3.jar jersey-core-1.18.1.jar jersey-servlet-1.18.1.jar jersey-server-1.18.1.jar
Comments
Post a Comment