You should never assign the current instance of the FacesContext
or any of its properties as a property of a managed bean. The current instance is only valid in the current HTTP request, it is destroyed by end of the HTTP request and not valid anymore in any subsequent HTTP requests.
You should always get the current instance in the method local scope.
public void addAction() {
if (commande.exists()) {
FacesContext.getCurrentInstance().addMessage("Commande", new FacesMessage(
FacesMessage.SEVERITY_ERROR, "Error Message : commande exists", null));
} else {
commandeService.create(commande);
}
}