json - java.io.IOException: Error writing to server in REST POST -


i use jersey rest client rest services in java spring mvc web application. trying post data using rest service application , data json string. use following code to post data:

objectmapper mapper = new objectmapper(); string jsonstring = mapper.writevalueasstring(myobject); clientconfig config = new defaultclientconfig(); client client = client.create(config); webresource webresource = client.resource(url); clientresponse responsemsg = webresource         .queryparam("jsondata", jsonstring         .post(clientresponse.class); string formmsg = responsemsg.getentity(string.class); 

here myobject object of type myobject pojo trying post. myobject contains string field in can store string of length. when try post using string of small length, able success message return if post success. when have sting large content, following exception:

com.sun.jersey.api.client.clienthandlerexception: java.io.ioexception: error writing server 

i believe exception due content length. there way can post data rest service of length.

adding stacktace below:

com.sun.jersey.api.client.clienthandlerexception: java.io.ioexception: error writing server     @ com.sun.jersey.client.urlconnection.urlconnectionclienthandler.handle(urlconnectionclienthandler.java:149)     @ com.sun.jersey.api.client.client.handle(client.java:648)     @ com.sun.jersey.api.client.webresource.handle(webresource.java:670)     @ com.sun.jersey.api.client.webresource.post(webresource.java:241)     @ com.smartwcm.services.cbrain.controller.cbrainlessoncontroller.savesaint(cbrainlessoncontroller.java:201)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:498)     @ org.springframework.web.method.support.invocablehandlermethod.doinvoke(invocablehandlermethod.java:221)     @ org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:137)     @ org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:110)     @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlemethod(requestmappinghandleradapter.java:777)     @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:706)     @ org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:85)     @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:943)     @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:877)     @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:966)     @ org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:868)     @ javax.servlet.http.httpservlet.service(httpservlet.java:644)     @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:842)     @ javax.servlet.http.httpservlet.service(httpservlet.java:725)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:291)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206)     @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:239)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:330)     @ org.springframework.security.web.access.intercept.filtersecurityinterceptor.invoke(filtersecurityinterceptor.java:118)     @ org.springframework.security.web.access.intercept.filtersecurityinterceptor.dofilter(filtersecurityinterceptor.java:84)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.access.exceptiontranslationfilter.dofilter(exceptiontranslationfilter.java:113)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.session.sessionmanagementfilter.dofilter(sessionmanagementfilter.java:103)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.authentication.anonymousauthenticationfilter.dofilter(anonymousauthenticationfilter.java:113)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.servletapi.securitycontextholderawarerequestfilter.dofilter(securitycontextholderawarerequestfilter.java:154)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.savedrequest.requestcacheawarefilter.dofilter(requestcacheawarefilter.java:45)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.authentication.www.basicauthenticationfilter.dofilter(basicauthenticationfilter.java:150)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.authentication.abstractauthenticationprocessingfilter.dofilter(abstractauthenticationprocessingfilter.java:199)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.authentication.logout.logoutfilter.dofilter(logoutfilter.java:110)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.context.request.async.webasyncmanagerintegrationfilter.dofilterinternal(webasyncmanagerintegrationfilter.java:50)     @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.context.securitycontextpersistencefilter.dofilter(securitycontextpersistencefilter.java:87)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.filterchainproxy.dofilterinternal(filterchainproxy.java:192)     @ org.springframework.security.web.filterchainproxy.dofilter(filterchainproxy.java:160)     @ org.springframework.web.filter.delegatingfilterproxy.invokedelegate(delegatingfilterproxy.java:344)     @ org.springframework.web.filter.delegatingfilterproxy.dofilter(delegatingfilterproxy.java:261)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:239)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206)     @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:219)     @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:106)     @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:501)     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:142)     @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:79)     @ org.apache.catalina.valves.abstractaccesslogvalve.invoke(abstractaccesslogvalve.java:610)     @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:88)     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:516)     @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1086)     @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:659)     @ org.apache.coyote.http11.http11nioprotocol$http11connectionhandler.process(http11nioprotocol.java:223)     @ org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun(nioendpoint.java:1558)     @ org.apache.tomcat.util.net.nioendpoint$socketprocessor.run(nioendpoint.java:1515)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617)     @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61)     @ java.lang.thread.run(thread.java:745) caused by: java.io.ioexception: error writing server     @ sun.net.www.protocol.http.httpurlconnection.writerequests(httpurlconnection.java:699)     @ sun.net.www.protocol.http.httpurlconnection.writerequests(httpurlconnection.java:711)     @ sun.net.www.protocol.http.httpurlconnection.getinputstream0(httpurlconnection.java:1567)     @ sun.net.www.protocol.http.httpurlconnection.getinputstream(httpurlconnection.java:1474)     @ java.net.httpurlconnection.getresponsecode(httpurlconnection.java:480)     @ com.sun.jersey.client.urlconnection.urlconnectionclienthandler._invoke(urlconnectionclienthandler.java:240)     @ com.sun.jersey.client.urlconnection.urlconnectionclienthandler.handle(urlconnectionclienthandler.java:147)     ... 74 more 


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -