HI All,
I am using Hibernate with JSF, and my backing bean contains method
public String add() {
if(title!=null){
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
//currentSession();
session.beginTransaction();
Event theEvent = new Event();
theEvent.setTitle(title);
theEvent.setDate(date);
session.save(theEvent);
session.getTransaction().commit();
return "success";
}
else {
return "failure";
}
}
and my HibernateUtil class contain
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
when i run my jsf application, i am getting exception:
javax.servlet.ServletException: #{GetNameBean.validated}: javax.faces.el.EvaluationException: java.lang.ExceptionInInitializerError
i dont know why.
please clarify me.
regards
Gopal
|