I am a newbie in spring boot and I have a scenario I cant figure out what I could be missing. I have created Common Error handler class to handle all my application errors and this work fine either when am using the spring boot embedded tomcat or local tomcat. But If I deploy the same war file to my digital ocean cloud server where have installed tomcat application does not call the @ControllerAdvice. Here is my spring boot code which I need help in to figure out what I could be missing or what I should do. In my cloud server am using open jdk 8 but on localhost am using jdk8
@Order(Ordered.HIGHEST_PRECEDENCE)
@ControllerAdvice
public class AppExceptionHandler extends ResponseEntityExceptionHandler
{
@ResponseBody
@ExceptionHandler(ValidationException.class)
public ResponseEntity<?> InvalidData(ValidationException e){
common.logException(e);
return response(common.BAD_REQUEST, "125# "+e.getMessage());
}
private ResponseEntity<ServerResponse> response(int code, String msg) {
return new ResponseEntity<>(new ServerResponse(code,msg
), HttpStatus.FORBIDDEN);
}
}
@Getter
@SuppressWarnings("serial")
@ResponseStatus(HttpStatus.FORBIDDEN)
public class ValidationException extends RuntimeException {
private Object[] params = null;
private String status_code;
public ValidationException(String message,String status_code) {
super(message);
this.status_code=status_code;
}
public ValidationException(String message, Throwable cause) {
super(message, cause);
}
public ValidationException(String message, Object[] params) {
super(message);
this.params = params;
}
}
@Data
public class RegModel{
@JsonProperty("EmailAddress")
private String email_address;
private String application_type;
private String admission_num;
}
@Data
@AllArgsConstructor
public class ResponseModel{
private int resp_code;
private String message;
}
@Service
public class MyService{
public <T> T createStudent(RegModel userCreationModel)
{
T response=null;
if(userCreationModel.getEmail_address()==null)
{
throw new ValidationException(new ResponseModel("Invalid Request",500);
}
}
}
and here is my post man request using local host

and here is deployed war file in cloud response same end points
