我正在使用基于XML的Spring配置Rest API项目。它使用java 7版本部署在apache tomcat上。它开始抛出异常。代码示例是:
for (TempDTO tempDTO : finalTempDTO.getData()) {
Integer candidateId = tempDTO.getId();
logger.info("--------------------------------------------");
logger.info("id: " + candidateId);
if(!candidateAlreadyInserted(candidateId)) {
if (!tempUtil.isEmpty(tempDTO.getOccupation())) {
occupation = tempDTO.getOccupation().replaceAll("(?s)<[^>]*>(\\s*<[^>]*>)*", " ").trim();
}
if (!tempUtil.isEmpty(tempDTO.getDescription())) {
description = tempDTO.getDescription().replaceAll("(?s)<[^>]*>(\\s*<[^>]*>)*", " ").replaceAll("[^a-zA-Z0-9\\\\.]+", " ").replace("\\n", " ").trim();
}
DataEntity dataEntity = new DataEntity();
dataEntity.setBhCandidateId(candidateId);
dataEntity.setDescription(description);
dataEntity.setOccupation(occupation);
dataRepository.save(dataEntity);
}
logger.info("--------------------------------------------");
}
当我执行请求时,它会抛出异常:
org.springframework.web.util.NestedServletException:处理程序处理失败;嵌套异常是java.lang.StackOverflowError org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1303) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:977) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) javax.servlet.http.HttpServlet.service(HttpServlet.java:620) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) org.springframework.web.multipart.support.MultipartFilter.doFilterInternal(MultipartFilter.java:118) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
根本原因:
java.lang.StackOverflowError的 java.util.regex.Pattern中的$ Curly.match(Pattern.java:4132) java.util.regex.Pattern中的$ BmpCharProperty.match(Pattern.java:3715) java.util.regex.Pattern中的$ Curly.match0(Pattern.java:4170) java.util.regex.Pattern中的$ Curly.match(Pattern.java:4132) java.util.regex.Pattern中的$ GroupHead.match(Pattern.java:4556) java.util.regex.Pattern中的$ Loop.match(Pattern.java:4683) java.util.regex.Pattern中的$ GroupTail.match(Pattern.java:4615) java.util.regex.Pattern中的$ BmpCharProperty.match(Pattern.java:3715) java.util.regex.Pattern中的$ Curly.match0(Pattern.java:4170) java.util.regex.Pattern中的$ Curly.match(Pattern.java:4132) java.util.regex.Pattern中的$ BmpCharProperty.match(Pattern.java:3715) java.util.regex.Pattern中的$ Curly.match0(Pattern.java:4170) java.util.regex.Pattern中的$ Curly.match(Pattern.java:4132) java.util.regex.Pattern中的$ GroupHead.match(Pattern.java:4556) java.util.regex.Pattern中的$ Loop.match(Pattern.java:4683) java.util.regex.Pattern中的$ GroupTail.match(Pattern.java:4615) java.util.regex.Pattern中$ BmpCharProperty.match(Pattern.java:3715)