Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Urgent need help in Hibernate Configuration file

Question posted by: ashi1290 (Newbie) on May 14th, 2008 11:38 AM
I am getting this error.....
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:120)
at com.author.hbn.HibernateUtil.<clinit>(HibernateUtil.java:12)
at com.author.app.Abhi.main(Abhi.java:13)

Configuration file looks like this

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration SYSTEM "hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@10.208.7.35:1521:SAPETRM</property>
<property name="connection.username">sapetrmdev</property>
<property name="connection.password">sapetrmdev</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<mapping resource="conf/Trader.hbm.xml"/>
</session-factory>
</hibernate-configuration>

Hibernate Util file where i am creating Connection Looks likes this...

package com.author.hbn;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.dom4j.*;
public class HibernateUtil {
private static final SessionFactory sessionFactory;

static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Exception 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;
}


}
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
JosAH's Avatar
JosAH
Chief Editor
7,206 Posts
May 14th, 2008
12:32 PM
#2

Re: Urgent need help in Hibernate Configuration file
It has nothing to do with Hibernate nor Connections; read the exception text: your
code is looking for a LogFactory and you didn't tell it where it could find one.

kind regards,

Jos

Reply
Reply
Not the answer you were looking for? Post your question . . .
178,103 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top Java Forum Contributors