I have following code in my backing bean:
try {
contractService.create(selectedContract);
conversation.end();
return "search?faces-redirect=true";
} catch (ActiveContractExistsException e) {
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, null, e.getMessage()));
return null;
}
In jsf:
<p:growl id="growl" showDetail="true" showSummary="false" closable="true" autoUpdate="true"/>
and
<p:commandButton value="Save" actionListener="#{contractView.update}" update="growl"/>
As a result I'm getting:
Like you can see this is far from SEVERITY_ERROR. But the most interesting part is when my code is following (adding message outside the catch block):
try {
contractService.create(selectedContract);
conversation.end();
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "Some message"));
return "search?faces-redirect=true";
} catch (ActiveContractExistsException e) {
//FacesContext context = FacesContext.getCurrentInstance();
//context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "Some message"/*e.getMessage()*/));
return null;
}
then all fine:
How can I set SEVERITY_ERROR level to my message while handling exception?


My problem relates with EE container. In case I'm not extended from EJBException they wrapping automatically, therefore block
catchdoesn't executing. There are two ways to solve my problem:@ApplicationExceptionannotation to my class exception