Hallo allerseits,
als Hibernate NewBi habe ich das Problem eine kleine Applikation zum Laufen zu Bewegen, diese soll mittels Hibernate3 auf eine HsqlDB zugreifen. Derzeit erhalte ich beim starten der App folgende Fehlermeldung:
java.lang.ExceptionInInitializerError
at test.main(test.java:19)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at test.common.HibernateUtil.<clinit>(HibernateUtil.java:10)
... 1 more
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
... 5 more
Caused by: java.lang.NullPointerException
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374)
... 6 more
Exception in thread "main"
Meine leere 'Test' main Methode:
Code:
public static void main(String[] args) {
session = HibernateUtil.currentSession();
tx = session.beginTransaction();
tx.commit();
session.close();
}
Ich habe eine valide
hibernate.cfg.xml & log4j.properties
HibernateUitl.java:
Code:
package test.common;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.*;
import org.hibernate.cfg.*;
public class HibernateUtil {
private static Log log = LogFactory.getLog(HibernateUtil.class);
public static SessionFactory sessionFactory = null;
public static final ThreadLocal session = new ThreadLocal();
static {
init();
}
private static void init(){
try {
Configuration config = new Configuration();
config.configure();
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = config.buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed.");
ex.printStackTrace();
throw new ExceptionInInitializerError(ex);
}
}
public static Session currentSession() throws HibernateException {
Session s = (Session) session.get();
// Open a new Session, if this thread has none yet
if (s == null) {
s = sessionFactory.openSession();
// Store it in the ThreadLocal variable
session.set(s);
}
return s;
}
public static void closeSession() throws HibernateException {
Session s = (Session) session.get();
if (s != null)
s.close();
session.set(null);
}
}
Ich kann mit der Fehlermeldung nichts anfangen, kann mir jemand einen Tipp geben?