Spring Rest Controller-java.lang.IllegalStateException:已连接

时间:2018-07-31 10:11:29

标签: spring

我已经定义了RestController(下面的示例代码)。我正在从request参数读取json正文。从我的服务中,我正在调用其他应用程序的另一个Rest端点。我收到“ java.lang.IllegalStateException:已连接”

def processPostRequest(request: HttpServletRequest): ResponseEntity[String] ={
val requestURI = request.getRequestURI
val customURI = requestURI.substring("/abc/xyz".size)
val queryString = request.getQueryString
val queryParameters = extractQueryParameters(queryString)
val httpMethod = request.getMethod.toLowerCase
val inputStream = request.getInputStream
val requestBody = IOUtils.toString(inputStream)


val response = Service.processGraphRequest(customURI,httpMethod,queryParameters, requestBody)
new ResponseEntity[String](response,HttpStatus.OK)

}

我收到以下异常。 java.lang.IllegalStateException:已连接     在sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:3071)〜[?:1.8.0_152]     在org.glassfish.jersey.client.internal.HttpUrlConnector.setOutboundHeaders(HttpUrlConnector.java:421)〜[jersey-client-2.22.1.jar :?]     在org.glassfish.jersey.client.internal.HttpUrlConnector.access $ 100(HttpUrlConnector.java:96)〜[jersey-client-2.22.1.jar :?]     在org.glassfish.jersey.client.internal.HttpUrlConnector $ 4.getOutputStream(HttpUrlConnector.java:384)〜[jersey-client-2.22.1.jar :?]     在org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:200)〜[jersey-common-2.22.1.jar :?]     在org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:194)〜[jersey-common-2.22.1.jar :?]     在org.glassfish.jersey.message.internal.CommittingOutputStream.commit(CommittingOutputStream.java:262)〜[jersey-common-2.22.1.jar :?]     在org.glassfish.jersey.message.internal.OutboundMessageContext.commitStream(OutboundMessageContext.java:816)〜[jersey-common-2.22.1.jar :?]     在org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:545)〜[jersey-client-2.22.1.jar :?]     在org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:388)〜[jersey-client-2.22.1.jar :?]     在org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:285)〜[jersey-client-2.22.1.jar :?]     在org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:255)〜[jersey-client-2.22.1.jar :?]     在org.glassfish.jersey.client.JerseyInvocation $ 1.call(JerseyInvocation.java:684)〜[jersey-client-2.22.1.jar :?]     在org.glassfish.jersey.client.JerseyInvocation $ 1.call(JerseyInvocation.java:681)〜[jersey-client-2.22.1.jar :?]     在org.glassfish.jersey.internal.Errors.process(Errors.java:315)〜[jersey-common-2.22.1.jar :?]     在org.glassfish.jersey.internal.Errors.process(Errors.java:297)〜[jersey-common-2.22.1.jar :?]     在org.glassfish.jersey.internal.Errors.process(Errors.java:228)〜[jersey-common-2.22.1.jar :?]     在org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444)〜[jersey-common-2.22.1.jar :?]     在org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:681)〜[jersey-client-2.22.1.jar:?]

有人可以帮助我解决问题吗?

0 个答案:

没有答案