By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,703 Members | 1,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,703 IT Pros & Developers. It's quick & easy.

Urgent need help in Hibernate Configuration file

P: 6
I am getting this error.....
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.hibernate.cfg.Configuration.<clinit>(Configura tion.java:120)
at com.author.hbn.HibernateUtil.<clinit>(HibernateUti l.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.OracleD river</property>
<property name="connection.url">jdbc:oracle:thin:@10.208.7.3 5: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.Oracle9Dialec t</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;
}


}
May 14 '08 #1
Share this Question
Share on Google+
1 Reply


Expert 10K+
P: 11,448
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
May 14 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.