在我的应用程序的 Azure Cosmo DocumentDB 中,出现以下错误
2018-03-27 14:42:057 错误 chmsCosmosDBFruiteService - 无法将 Fruites 添加到客户参考:11416e34-3620-45a4-b3be-b845bbf41762
消息:{“错误”:[“具有指定 ID 或名称的资源已经存在。”] }ActivityId:1b70b944-d581-4640-8785-819400433bb4,请求 URI:/apps/8d13f597-c7e4-4d60-8713-8a0e9abaa9ac/services/ce0d287f-0125-482b-b32c-22108b5320ed3/cf8c-a292/d8c-a24/4 9937ecea8dcc/replicas/131662740073245648p,RequestStats:,SDK:Microsoft.Azure.Documents.Common/1.21.0.0,StatusCode:冲突 2018-03-27 14:42:058 错误 chmaeGlobalExceptionHandler - 异常:类 org.apache.catalina.connector。 ClientAbortException 消息:java.io.IOException:现有连接被远程主机强行关闭 2018-03-27 14:42:058 警告 oswsmmaExceptionHandlerExceptionResolver - 无法调用 @ExceptionHandler 方法:公共 java.util.Map com.hm.myfeed .api.exception.GlobalExceptionHandler.handleException(java.lang.Exception,org.springframework.web.context.request.WebRequest,javax.servlet.http.HttpServletRequest) org.apache.catalina.connector.ClientAbortException: java.io.IOException: org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:356) 处的远程主机强行关闭了现有连接。 org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:815) 在 org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:720) 在 org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer. java:391) 在 org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:369) 在 org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96) 在 org.springframework.security.web .util.OnCommittedResponseWrapper$SaveContextServletOutputStream.write(OnCommittedResponseWrapper.java:639)catalina.connector.ClientAbortException: java.io.IOException: org.apache.catalina.connector 的 org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:356) 上的远程主机强行关闭了现有连接。 OutputBuffer.flushByteBuffer(OutputBuffer.java:815) 在 org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:720) 在 org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:391) 在 org .apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:369) at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96) at org.springframework.security.web.util.OnCommittedResponseWrapper$SaveContextServletOutputStream .write(OnCommittedResponseWrapper.java:639)catalina.connector.ClientAbortException: java.io.IOException: org.apache.catalina.connector 的 org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:356) 上的远程主机强行关闭了现有连接。 OutputBuffer.flushByteBuffer(OutputBuffer.java:815) 在 org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:720) 在 org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:391) 在 org .apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:369) at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96) at org.springframework.security.web.util.OnCommittedResponseWrapper$SaveContextServletOutputStream .write(OnCommittedResponseWrapper.java:639)org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:815) 的 org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:356) 的远程主机强行关闭了现有连接.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:720) 在 org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:391) 在 org.apache.catalina.connector.OutputBuffer.write(OutputBuffer .java:369) 在 org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96) 在 org.springframework.security.web.util.OnCommittedResponseWrapper$SaveContextServletOutputStream.write(OnCommittedResponseWrapper.java:639)org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:815) 的 org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:356) 的远程主机强行关闭了现有连接.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:720) 在 org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:391) 在 org.apache.catalina.connector.OutputBuffer.write(OutputBuffer .java:369) 在 org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96) 在 org.springframework.security.web.util.OnCommittedResponseWrapper$SaveContextServletOutputStream.write(OnCommittedResponseWrapper.java:639)realWriteBytes(OutputBuffer.java:356) 在 org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:815) 在 org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:720) 在 org.apache .catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:391) 在 org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:369) 在 org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java :96) 在 org.springframework.security.web.util.OnCommittedResponseWrapper$SaveContextServletOutputStream.write(OnCommittedResponseWrapper.java:639)realWriteBytes(OutputBuffer.java:356) 在 org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:815) 在 org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:720) 在 org.apache .catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:391) 在 org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:369) 在 org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java :96) 在 org.springframework.security.web.util.OnCommittedResponseWrapper$SaveContextServletOutputStream.write(OnCommittedResponseWrapper.java:639)OutputBuffer.writeBytes(OutputBuffer.java:391) at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:369) at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96) at org .springframework.security.web.util.OnCommittedResponseWrapper$SaveContextServletOutputStream.write(OnCommittedResponseWrapper.java:639)OutputBuffer.writeBytes(OutputBuffer.java:391) at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:369) at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96) at org .springframework.security.web.util.OnCommittedResponseWrapper$SaveContextServletOutputStream.write(OnCommittedResponseWrapper.java:639)
我不明白这一点。异常发生在首先检查集合是否存在(它确实存在)然后是否不创建它的代码中。显然创建将失败,集合存在!
创建函数
try {
fruitesDocument = documentClient.createDocument(getCollectionLink(), fruitesDocument , null, false).getResource();
} catch (DocumentClientException e) {
LOG.error("Could not add fruits for Customer Reference: " + fruitesModel.getId() + " " + e.getMessage());
}
更新功能:
try {
fruitesDocument = documentClient.replaceDocument(fruitesDocument , null).getResource();
} catch (DocumentClientException e) {
LOG.error("Error while updating fruites: " + e.getMessage());
}
创建文档时遇到问题。