Questions tagged [controller-advice]
113 questions
0
votes
0 answers
ControllerAdvice is not triggered in my springboot application?
Actually I am working in a Kafka streams application using Spring Boot.
So here I am trying to handle exceptions globally using @ControllerAdvice but it is not working for me.
Is it possible to use @ControllerAdvice in my application.
Is this…

RandomUser
- 31
- 1
- 8
0
votes
1 answer
Spring ControllerAdvice does not return response body?
I have the following ControllerAdvice, that handles JsonParseException (I use Spring and Jackson)
@ControllerAdvice
public class ControllerExceptionHandler extends ResponseEntityExceptionHandler {
@ExceptionHandler(JsonParseException.class)
…

jhthewow
- 133
- 1
- 3
- 12
0
votes
1 answer
@controlleradvice giving error : scope 'session' is not active for current thread
I am facing an issue with Spring mvc annotation @Controlleradvice.
I have 2 controller classes: UserGapsController and RegistrationBaseController
Both classes use
@Controller
@Controlleradvice
@Autowired session…

Shweta Priyadarshani
- 236
- 4
- 16
0
votes
0 answers
MissingServletRequestParameterException not getting caught using @ControllerAdvice
I'm trying to make a global exception handler, below is the code for that. Other exceptions are getting caught but MissingServletRequestParameterException isn't. I tried overriding handleMissingServletRequestParameter as well but didn't had much…

Sanchit Mittal
- 1
- 1
- 2
0
votes
1 answer
Java Spring exception handling
I have multiple controllers whose exceptions are handled in the ControllerAdvice.
All controllers use common exceptions types (like HttpClientException, DBException, etc.).
But there is one specific controller which exceptions should be handled…

iJoker0998
- 21
- 3
0
votes
2 answers
Approach to handle exception in Spring Boot. Throw exception catch and throw the same exception, is it a bad practice?
I'm working with spring boot and I'm dealing with a good way to handle exceptions:
I have this case where interact with a repository to get a product. But what about if there is a connection issue with the DB, I'm not going to catch that…

Julio
- 429
- 2
- 16
0
votes
0 answers
Output message is not getting displayed when @ModelAttribute is used with @ControllerAdvice in Spring MVC
I am trying to add ModelAttribute value to different pages within the same application with the help of ControllerAdvice but output message is not getting displayed on the jsp pages.
ServicesController.java
package com.test;
@Controller
public…

Harry
- 65
- 1
- 2
- 9
0
votes
2 answers
SpringBoot handle all errors with custom error in ControllerAdvice
I have a REST api spring boot application and would like to handle any error in ControllerAdvice, because I would like to have a customised response format and not use the Spring default response.
For example Exception like RequestRejectedException…

simonC
- 4,101
- 10
- 50
- 78
0
votes
1 answer
Accessing ModelView attributes in Spring ResponseBodyAdvice
For all my RestControllers handlers, which all return a subtype of MyResponseType, I would like to write a Spring ResponseBodyAdvice which manipulates the response based on some @ModelAttribute. However, I don't know how to access the ModelView at…

rainer198
- 3,195
- 2
- 27
- 42
0
votes
1 answer
Spring Boot catch multiple exceptions and send as error response
I am validating an incoming POST request which will create a database entity after validating the request data. I am trying to gather multiple errors in a single request and respond as error response following JSON API…

iamcrypticcoder
- 2,609
- 4
- 27
- 50
0
votes
1 answer
Controller Advice not handling FileTooLargeException by exceuting method annotated with FileTooLargeException
My rest controller contains following post mapping :
@PostMapping
public ResponseEntity uploadDocument(@ModelAttribute @Valid RequestDTO requestDTO,@RequestParam(value = "fileContent") MultipartFile fileContent) throws …

user2477173
- 49
- 5
0
votes
2 answers
How to print the Controller method name in @ControllerAdvice?
I went through link: How to find controller name in @controllerAdvice or @RestControllerAdvice in Spring MVC? many times, but I am looking to get the Controller methodname in @ControllerAdvice class.
Here is my CustomHandler…

PAA
- 1
- 46
- 174
- 282
0
votes
1 answer
Exclude methods from @ModelAttribute in @RestControllerAdvice
I have the following controller:
@RestController
@RequestMapping("/api/{brand}"
public class CarController {
@GetMapping
public List getCars(@PathVariable("brand") String brand) {
// Some implementation
}
@GetMapping("/{model}")
…

Titulum
- 9,928
- 11
- 41
- 79
0
votes
0 answers
Spring Boot REST CustomException using ControllerAdvice Not Showing in logs or stdout
In a project which uses Java 1.8, lombok and Spring Boot 2.1.5.RELEASE, created a custom exception which is not showing up anywhere in my logs files or stdout.
pom.xml:
org.springframework.boot
…

PacificNW_Lover
- 4,746
- 31
- 90
- 144
0
votes
0 answers
@ControllerAdvice does not catch MySQLIntegrityConstraintViolationException
I am making a Spring Boot app with MySQL database attached to it.
I have already marked username as unique in the user-table, and the DB throws a MySQLIntegrityConstraintViolationException when i try to add a new user with an existing username.
Is…

Lazaruss
- 1,107
- 1
- 13
- 24