我知道标题不是最好的,但是错误对我来说一点都不清楚。我的错误是这样的:
019-04-15 14:28:45.270 ERROR 12644 --- [nio-9090-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.StackOverflowError] with root cause
java.lang.StackOverflowError: null
at com.google.gson.stream.JsonWriter.writeDeferredName(JsonWriter.java:401) ~[gson-2.8.5.jar:na]
at com.google.gson.stream.JsonWriter.value(JsonWriter.java:480) ~[gson-2.8.5.jar:na]
at com.google.gson.internal.bind.TypeAdapters$3.write(TypeAdapters.java:148) ~[gson-2.8.5.jar:na]
at com.google.gson.internal.bind.TypeAdapters$3.write(TypeAdapters.java:133) ~[gson-2.8.5.jar:na]
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) ~[gson-2.8.5.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:127) ~[gson-2.8.5.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:245) ~[gson-2.8.5.jar:na]
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) ~[gson-2.8.5.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:127) ~[gson-2.8.5.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:245) ~[gson-2.8.5.jar:na]
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) ~[gson-2.8.5.jar:na]
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:97) ~[gson-2.8.5.jar:na]
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:61) ~[gson-2.8.5.jar:na]
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) ~[gson-2.8.5.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:127) ~[gson-2.8.5.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:245) ~[gson-2.8.5.jar:na]
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) ~[gson-2.8.5.jar:na]
at
[...]
[...]
是因为这些行重复了一段疯狂的时间,并且它们都是一样的。对于我通过搜索错误所了解的内容,它应该是递归性和无限循环的问题,但是在我的代码中我不知道它在哪里。
这就是我正在调用的方法:
@PostMapping(path=PathConstants.START_ACTION)
public ResponseEntity<BaseResponse<ProcessInstance>> start(@PathVariable String processDefinitionId, @RequestBody(required=false) Map<String,Object> params) throws FileNotFoundException {
LOGGER.info("starting process definition with id {}", processDefinitionId);
ResponseEntity<BaseResponse<ProcessInstance>> response = null;
ProcessInstance pi = null;
LocalDateTime time = LocalDateTime.now();
try {
if(params!=null) {
pi = runtimeService.startProcessInstanceById(processDefinitionId, params);
List<org.flowable.task.api.Task> tasks = taskService.createTaskQuery().list();
System.out.println("Length " + tasks.get((tasks.size()-1)).getProcessVariables());
org.flowable.task.api.Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
if(task==null) {
System.out.println("Task is null");
} else {
System.out.println("Info task " + runtimeService.getVariables(pi.getId()));
}
} else {
System.out.println("Empty ");
pi = runtimeService.startProcessInstanceById(processDefinitionId);
}
response = new ResponseEntity<>(new BaseResponse<>(Constants.OK, pi), HttpStatus.OK);
MongoOperations.writeLogSuccess(pi ,pi.getProcessDefinitionName(), "OK"); //if it went well
} catch (FlowableObjectNotFoundException e) {
String pdn = repositoryService.getProcessDefinition(processDefinitionId).getName();
MongoOperations.writeLogFailure(time, pdn, "KO not found");
response = new ResponseEntity<>(new BaseResponse<>(e.getMessage(), null), HttpStatus.NOT_FOUND);
}
catch (FlowableException e) { //TEST EXCEPTION WITH FAILSTATUSCODE
String pdn = repositoryService.getProcessDefinition(processDefinitionId).getName();
MongoOperations.writeLogFailure(time, pdn, "KO flowable");
response = new ResponseEntity<>(new BaseResponse<>(e.getMessage(), null), HttpStatus.INTERNAL_SERVER_ERROR); //other exception are managed here
} catch(Exception e) {
String pdn = repositoryService.getProcessDefinition(processDefinitionId).getName();
MongoOperations.writeLogFailure(time, pdn, "KO general");
response = new ResponseEntity<>(new BaseResponse<>(e.getMessage(), null), HttpStatus.INTERNAL_SERVER_ERROR); //other exception are managed here
}
return response;
}
我真的不明白是什么原因以及原因。我要通过发布请求传递的params
是这样写的Json字符串:
{
"input":2
}