I was working in my spring boot application with an already existing remote postgres database. Now I need to work with a different Database that I set up locally, but I have some problems. I have divided in two class the endpoints related to the definitons of processes and the ones related to the instances. The controller class with the instance endpoint uses a HistoryService
to perform operations on the database. The class does, for example, this:
@Autowired
private HistoryService historyService;
@Autowired
private ProcessInstanceService processInstanceService;
/**
* Returns all historical process instances
* @return List<{@link HistoricProcessInstance}>> the list of all process instances
*/
@GetMapping
public ResponseEntity<BaseResponse<List<HistoricProcessInstance>>> listAllProcessInstance() {
BaseResponse<List<HistoricProcessInstance>> body = new BaseResponse<>();
ResponseEntity<BaseResponse<List<HistoricProcessInstance>>> response = null;
List<HistoricProcessInstance> l;
try {
l = historyService.createHistoricProcessInstanceQuery().list();
if (CollectionUtils.isEmpty(l)) {
body.setData(null);
body.setMessage("No history found");
response = new ResponseEntity<>(body, HttpStatus.OK);
} else {
body.setData(l);
body.setMessage(Constants.OK);
response = new ResponseEntity<>(body, HttpStatus.OK);
}
} catch (Exception e) {
response = new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
}
return response;
}
This method, for example, returns all history of process instances. Since I moved to a new DB, it returns of course the message "No history found"
, and that’s ok.
Now, the problem is with the process definitions controller. I have a similar method to retrieve all definitions:
@Autowired
private RepositoryService repositoryService;
@Autowired
private RuntimeService runtimeService;
@Autowired
private DeploymentService deploymentService;
/**
* Returns a list of process definitions (all processes that were deployed)
* @return a response Entity with a List<{@link ProcessDefinition}>> as body
*/
@GetMapping
public ResponseEntity<BaseResponse<?>> listProcessDefinition() {
LOGGER.debug("retrieving process definition list");
BaseResponse<List<ProcessDefinition>> body = new BaseResponse<>();
ResponseEntity<BaseResponse<?>> response = null;
List<ProcessDefinition> processDefinitionList = repositoryService.createProcessDefinitionQuery().list();
LOGGER.debug("retrieved {} process definitions", processDefinitionList.size());
if (CollectionUtils.isEmpty(processDefinitionList)) {
body.setMessage("There are no processes deployed.");
response = new ResponseEntity<>(body, HttpStatus.NO_CONTENT);
} else {
body = new BaseResponse<>(Constants.OK, processDefinitionList);
response = new ResponseEntity<>(body, HttpStatus.OK);
}
return response;
}
The problem is that, in this case, if I perform a GET to this endpoint and the method is called, the browser doesn’t show anything, the page is not loaded, no message is shown. So I thought it was an empty database problem, but I don’t know how to fix it… My question is: why, in this case, since the processDefinitionList
is empty, no message is shown on the browser and with the process instances is shown. Is it because one uses HistoryService and one RepositoryService? In what are they different? How can I manage this?
To clarify: to change my database, all I did was changing connection informations inside application.properties
file