java - POSTing a file to resteasy -
i'm getting error @ bottom of post. can spot issue?
resteasy http call:
@post @path("/") public void upload(final @multipartform fileuploadform form) { log.info(string.format("/%s/%s/%s/%s", form.geta(), form.getb(), form.getc(), form.getd())); }
associated java model:
private class fileuploadform { private string a; private string b; private string c; private string d; private byte[] file; @formparam("a") @parttype(mediatype.text_plain) public void seta(final string a) { this.a = a; } public string geta() { return a; } @formparam("b") @parttype(mediatype.text_plain) public void setb(final string b) { this.b = b; } public string getb() { return b; } @formparam("c") @parttype(mediatype.text_plain) public void setc(final string c) { this.c = c; } public string getc() { return c; } @formparam("d") @parttype(mediatype.text_plain) public void setd(final string d) { this.d = d; } public string getd() { return d; } @formparam("file") @parttype(mediatype.application_octet_stream) public void setfile(final byte[] file) { this.file = file; } public byte[] getfile() { return file; } }
jquery calling code:
$('div#upload form').submit(function() { $.ajax({ 'url': '/api/', 'type': 'post', 'data': new formdata($('div#upload form')[0]), 'contenttype': false, 'cache': false, 'processdata': false }); return false; });
also same result calling curl:
curl -f file=testimage.jpg http://hostname/api/
error:
18:11:33,890 warn [org.jboss.resteasy.core.exceptionhandler] (default task-37) failed executing post /: org.jboss.resteasy.spi.readerexception @ org.jboss.resteasy.plugins.providers.multipart.multipartformannotationreader.readfrom(multipartformannotationreader.java:64) [resteasy-multipart-provider-3.0.1.final.jar:] @ org.jboss.resteasy.core.interception.abstractreaderinterceptorcontext.readfrom(abstractreaderinterceptorcontext.java:59) [resteasy-jaxrs-3.0.1.final.jar:] @ org.jboss.resteasy.core.interception.serverreaderinterceptorcontext.readfrom(serverreaderinterceptorcontext.java:62) [resteasy-jaxrs-3.0.1.final.jar:] @ org.jboss.resteasy.core.interception.abstractreaderinterceptorcontext.proceed(abstractreaderinterceptorcontext.java:51) [resteasy-jaxrs-3.0.1.final.jar:] @ org.jboss.resteasy.security.doseta.digitalverificationinterceptor.aroundreadfrom(digitalverificationinterceptor.java:32) [resteasy-crypto-3.0.1.final.jar:] @ org.jboss.resteasy.core.interception.abstractreaderinterceptorcontext.proceed(abstractreaderinterceptorcontext.java:53) [resteasy-jaxrs-3.0.1.final.jar:] @ org.jboss.resteasy.plugins.interceptors.encoding.gzipdecodinginterceptor.aroundreadfrom(gzipdecodinginterceptor.java:59) [resteasy-jaxrs-3.0.1.final.jar:] @ org.jboss.resteasy.core.interception.abstractreaderinterceptorcontext.proceed(abstractreaderinterceptorcontext.java:53) [resteasy-jaxrs-3.0.1.final.jar:] @ org.jboss.resteasy.core.messagebodyparameterinjector.inject(messagebodyparameterinjector.java:150) [resteasy-jaxrs-3.0.1.final.jar:] @ org.jboss.resteasy.core.methodinjectorimpl.injectarguments(methodinjectorimpl.java:88) [resteasy-jaxrs-3.0.1.final.jar:] @ org.jboss.resteasy.core.methodinjectorimpl.invoke(methodinjectorimpl.java:111) [resteasy-jaxrs-3.0.1.final.jar:] @ org.jboss.resteasy.core.resourcemethodinvoker.invokeontarget(resourcemethodinvoker.java:272) [resteasy-jaxrs-3.0.1.final.jar:] @ org.jboss.resteasy.core.resourcemethodinvoker.invoke(resourcemethodinvoker.java:229) [resteasy-jaxrs-3.0.1.final.jar:] @ org.jboss.resteasy.core.resourcemethodinvoker.invoke(resourcemethodinvoker.java:216) [resteasy-jaxrs-3.0.1.final.jar:] @ org.jboss.resteasy.core.synchronousdispatcher.invoke(synchronousdispatcher.java:356) [resteasy-jaxrs-3.0.1.final.jar:] @ org.jboss.resteasy.core.synchronousdispatcher.invokepropagatenotfound(synchronousdispatcher.java:217) [resteasy-jaxrs-3.0.1.final.jar:] @ org.jboss.resteasy.plugins.server.servlet.servletcontainerdispatcher.service(servletcontainerdispatcher.java:224) [resteasy-jaxrs-3.0.1.final.jar:] @ org.jboss.resteasy.plugins.server.servlet.filterdispatcher.dofilter(filterdispatcher.java:59) [resteasy-jaxrs-3.0.1.final.jar:] @ io.undertow.servlet.core.managedfilter.dofilter(managedfilter.java:56) [undertow-servlet-1.0.0.beta3.jar:1.0.0.beta3] @ io.undertow.servlet.handlers.filterhandler$filterchainimpl.dofilter(filterhandler.java:132) [undertow-servlet-1.0.0.beta3.jar:1.0.0.beta3] @ io.undertow.servlet.handlers.filterhandler.handlerequest(filterhandler.java:85) [undertow-servlet-1.0.0.beta3.jar:1.0.0.beta3] @ io.undertow.servlet.handlers.security.servletsecurityrolehandler.handlerequest(servletsecurityrolehandler.java:56) [undertow-servlet-1.0.0.beta3.jar:1.0.0.beta3] @ io.undertow.servlet.handlers.servletdispatchinghandler.handlerequest(servletdispatchinghandler.java:36) [undertow-servlet-1.0.0.beta3.jar:1.0.0.beta3] @ org.wildfly.extension.undertow.security.securitycontextassociationhandler.handlerequest(securitycontextassociationhandler.java:78) @ io.undertow.servlet.handlers.security.sslinformationassociationhandler.handlerequest(sslinformationassociationhandler.java:115) [undertow-servlet-1.0.0.beta3.jar:1.0.0.beta3] @ io.undertow.security.handlers.authenticationcallhandler.handlerequest(authenticationcallhandler.java:52) [undertow-core-1.0.0.beta3.jar:1.0.0.beta3] @ io.undertow.security.handlers.abstractconfidentialityhandler.handlerequest(abstractconfidentialityhandler.java:45) [undertow-core-1.0.0.beta3.jar:1.0.0.beta3] @ io.undertow.servlet.handlers.security.cachedauthenticatedsessionhandler.handlerequest(cachedauthenticatedsessionhandler.java:65) [undertow-servlet-1.0.0.beta3.jar:1.0.0.beta3] @ io.undertow.security.handlers.securityinitialhandler.handlerequest(securityinitialhandler.java:70) [undertow-core-1.0.0.beta3.jar:1.0.0.beta3] @ io.undertow.server.handlers.predicatehandler.handlerequest(predicatehandler.java:25) [undertow-core-1.0.0.beta3.jar:1.0.0.beta3] @ org.wildfly.extension.undertow.security.securitycontextcreationhandler.handlerequest(securitycontextcreationhandler.java:54) @ io.undertow.server.handlers.predicatehandler.handlerequest(predicatehandler.java:25) [undertow-core-1.0.0.beta3.jar:1.0.0.beta3] @ io.undertow.servlet.handlers.servletinitialhandler.handlefirstrequest(servletinitialhandler.java:185) [undertow-servlet-1.0.0.beta3.jar:1.0.0.beta3] @ io.undertow.servlet.handlers.servletinitialhandler.dispatchrequest(servletinitialhandler.java:172) [undertow-servlet-1.0.0.beta3.jar:1.0.0.beta3] @ io.undertow.servlet.handlers.servletinitialhandler.access$000(servletinitialhandler.java:56) [undertow-servlet-1.0.0.beta3.jar:1.0.0.beta3] @ io.undertow.servlet.handlers.servletinitialhandler$1.handlerequest(servletinitialhandler.java:107) [undertow-servlet-1.0.0.beta3.jar:1.0.0.beta3] @ io.undertow.server.httphandlers.executeroothandler(httphandlers.java:36) [undertow-core-1.0.0.beta3.jar:1.0.0.beta3] @ io.undertow.server.httpserverexchange$1.run(httpserverexchange.java:629) [undertow-core-1.0.0.beta3.jar:1.0.0.beta3] @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) [rt.jar:1.7.0_25] @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) [rt.jar:1.7.0_25] @ java.lang.thread.run(thread.java:724) [rt.jar:1.7.0_25]
ugh. seem have figured out. fileuploadform inner class within resteasy class upload method.
splitting out own class has got working. crazy.
Comments
Post a Comment