I want to make a web application using JSF 2.0 and Hibernate. I want to log exceptions in a data base[Asynchronously].
How can I do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The information you give in your question is a bit meager really, but I’ll give it a shot anyway.
Limiting exception logging to those that occur during request processing (as per your comment), your first step would be to install a Servlet Filter:
If you already have other filters installed, you’ll probably need a
web.xmlto tune the order in which they are called.The next step is to do the asynchronous persisting to a DB. Here it depends on what stack you are using beyond JSF and Hibernate. For instance, Java EE has a convenient
@Asynchronousannotation here, while in Spring it’s@Async. In general JSF is most often combined with Java EE, but people saying they’re using Hibernate instead of JPA typically tend to be on Tomcat.For Java EE you would inject an EJB in the Filter, with the EJB using JPA (possibly Hibernate) and the mentioned
@Asynchronousannotation:Filter:
EJB: