Я знаю, что название не самое лучшее, но ошибка мне не совсем понятна. У меня ошибка такая:
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
Я передаю запрос post - это строка Json, написанная таким образом:
{
"input":2
}