3
I’m trying to capture a javax.validation.ValidationException
in my MB to later play an alert. I tried with the three examples below independent but nothing returned. Should I enter any more code ? I use version 2.5.0.
@ViewController
public class MeuMB extends AbstractEditPageBean<CTe, Long> {
@ExceptionHandler
public void tratar(RuntimeException ex) {
System.out.println("1111" + ex);
}
@ExceptionHandler
public void tratar2(ValidationException ex) {
System.out.println("2222" + ex);
}
@ExceptionHandler
public void tratar3(Exception ex) {
System.out.println("3333" + ex);
}
The class has @Viewcontroller and it already calls @Controller.
My calling method is as follows::
public String upload() {
//int i = 5 / 0;
try {
this.gera();
} catch (Exception ex) {
getMessageContext().add(getResourceBundle().getString("cte.msg.uploadFail"), SeverityType.ERROR);
return null;
}
If I take the comment from "5 / 0", error occurs and it is called the Runtimeexception. So the calls and Imports would be ok.
Problem is that in the "generate" method I force null into a field not null. Only to test.
@NotNull
@JoinColumn(name = "municipio_id", referencedColumnName = "id")
@ManyToOne(optional = false)
private Municipio municipio;
And this mistake I am not able to capture neither in Try catch nor by calls Exceptionhandler.