here is my custom exception
@ApplicationException @Redirect(viewId="genericErrorPage.xhtml") public class FraudException extends Exception { public FraudException(){} }
. . . <body> <h:messages globalOnly="true" styleClass="message" id="globalMessages" /> </body> </html>
private void doQry(String qry) throws FraudException { Connection con = null; Statement st = null; try { con = ds.getConnection(); st = con.createStatement(); ResultSet rs = st.executeQuery(qry); caseList.clear(); while (rs.next()) { caseList.add(new Tblcase(rs.getObject(1), rs.getObject(2), rs .getObject(3), rs.getObject(4), rs.getObject(5), rs .getObject(6), rs.getObject(7), rs.getObject(8), rs .getObject(9), rs.getObject(10), rs.getObject(11), rs .getObject(12))); } } catch (Exception e) { e.printStackTrace(); log.error("ERROR: " + e.getMessage()); facesMessages.add("ERROR RENDERING DATA: " + e.getMessage()); throw new FraudException(); } finally { try { con.close(); st.close(); } catch (Exception e) { e.printStackTrace(); log.error("ERROR: " + e.getMessage()); facesMessages.add("ERROR CLOSING CONNECTIONS: " + e.getMessage()); throw new FraudException(); } }