-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: how to resolve java.lang.ExceptionInInitializerError???
PostPosted: Tue Jan 17, 2006 3:06 pm 
Beginner
Beginner

Joined: Thu Jan 12, 2006 7:38 pm
Posts: 25
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 17, 2006 4:44 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Can you post, using code tags, the full exception that buildSessionFactory() is throwing?

As a matter of interest, why are you wrapping Errors and RuntimeExceptions in an ExeptionInInitializerError? It may be valid, but you're wrapping unchecked exceptions and JVM exceptions unnecessarily; those exceptions would propagate correctly without being wrapped in another Error.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.