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.  [ 7 posts ] 
Author Message
 Post subject: Probleme mit Hibernate3 als Standalone
PostPosted: Fri Jul 22, 2005 12:58 pm 
Newbie

Joined: Fri Jul 22, 2005 12:40 pm
Posts: 4
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?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 22, 2005 5:50 pm 
Beginner
Beginner

Joined: Fri Jul 08, 2005 8:09 am
Posts: 28
Vielleicht fehlt das commons-logging-x.y.z.jar im libpath?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 22, 2005 6:27 pm 
Newbie

Joined: Fri Jul 22, 2005 12:40 pm
Posts: 4
Nein dieses Jar fehlt nicht, hier eine Auszug des lib Verzeichnis:
    log4j-1.2.9.jar
    xerces-2.6.2.jar
    hsqldb.jar
    dom4j-1.6.jar
    hibernate3.jar
    activation.jar
    commons-collections-2.1.1.jar
    commons-logging-1.0.4.jar
    junit-3.8.1.jar


Daran liegt es nicht es nicht.


Top
 Profile  
 
 Post subject: zusätzlicher HInweis
PostPosted: Fri Jul 22, 2005 6:50 pm 
Newbie

Joined: Fri Jul 22, 2005 12:40 pm
Posts: 4
Nachdem ich Einträge in anderen Foren mit ähnlichen Problemen wie meines gefunden habe, muss ich einen weiteren Hinweis geben. Ich versuchte die Methode 'main' aus Eclipse heraus zu starten.

Eclipse Version: 3.1.0 Build id: I20050610-1757
java.runtime.version=1.4.2_03-b02


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 23, 2005 10:24 am 
Beginner
Beginner

Joined: Fri Jul 08, 2005 8:09 am
Posts: 28
Wenn gar nichts anderes hilft, würd ich mir den Source vom commons logging besorgen, und nachsehen was hier schief läuft (LogFactoryImpl.java:543). In Eclipse kannst du auch einfach das src Verzeichnis an das jar binden und dann durch den Code steppen bzw einen Breakpoint setzen. Immer noch besser, als im Dunkeln zu tappen und gar nicht weiterzukommen...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 25, 2005 6:37 am 
Newbie

Joined: Fri Jul 22, 2005 12:40 pm
Posts: 4
Durch das debuggen erhielt ich die Information, dass der Classloader nicht ermittelt werden kann (cl=null) wenn man ein Hibernate Example mit common-logging-1.0.4.jar unter Eclipse startet.

Um das Problem unter Eclipse zu beheben ist es notwendig sich die aktuelle Version von common-logging zu besorgen, im Moment 1.0.5 alpha. In dieser Version wird nicht versucht aus dem 'bootstrap classpath' den Classloader zu holen.

Mein Empfehlung ist daher die Version 1.0.5 einzusetzen, mit einem offiziellen Relase kann man noch im August rechnen.

cu Mike


Top
 Profile  
 
 Post subject: I had the same problem
PostPosted: Sat Jan 20, 2007 5:29 pm 
Newbie

Joined: Sat Jan 20, 2007 5:18 pm
Posts: 1
it happens to me when i use commons-logging-1.0.4 (which comes with cactus ) in Eclipse 3.1, but when changed to use commons-logging1.1, works.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.