I am using Hibernate 3.2.1GA and Annotations 3.2.1GA.
Before i was using hbm.xml files and everything was working fine, but since I've switch to using annotations (and deleting my hbm.xml files) my HibernateUtil.java class throws a:
java.lang.NoClassDefFoundError: Could not initialize class
I've been trying to figure out why this is happening, but i cannot figure it out. Here is my Hibernate Util...
Code:
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static{
try{
AnnotationConfiguration cfg = new AnnotationConfiguration();
cfg.configure("hibernate.cfg.xml");
cfg.setPrecedence("class");
sessionFactory = cfg.buildSessionFactory();
}catch(Throwable hb){
throw new ExceptionInInitializerError(hb);
}
}
private static final ThreadLocal <Session>localSession = new ThreadLocal<Session>();
public static Session currentSession(){
/*Session s = (Session)localSession.get();
if(s == null){
s = sessionFactory.openSession();
localSession.set(s);
}
*/
return sessionFactory.openSession();
}
public static void closeSession(Session session)throws HibernateException{
session = localSession.get();
if(session != null){
session.close();
localSession.set(null);
}
}
}
btw, i'm using JEE5 and jdk6