-->
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.  [ 6 posts ] 
Author Message
 Post subject: Severe error
PostPosted: Tue Mar 14, 2006 9:54 am 
Newbie

Joined: Tue Mar 14, 2006 9:44 am
Posts: 3
Hello friends,
i'm a beginner in hibernate, when i tried an example i got this error. plz help me rectify the problem

Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/apach
e/commons/logging/LogFactory
Exception in thread "main" java.lang.ExceptionInInitializerError
at de.gloegl.road2hibernate.HibernateUtil.<clinit>(HibernateUtil.java:22
)
at de.gloegl.road2hibernate.EventManager.main(EventManager.java:11)
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:110)
at de.gloegl.road2hibernate.HibernateUtil.<clinit>(HibernateUtil.java:14
)
... 1 more


Note:
This is my application path
D:\Program Files\apache-tomcat-5.5.12\webapps\part1

in part1/lib directory i h'v placed all the jar files including hibernate3.jar,commons-httpclient.jar,mysql-connector-java-3.0.16-ga-bin.jar and commons-logging-1.0.4.jar etc.,

set the classpath as

%classpath%;D:\Program Files\Java\jdk1.5.0\lib\tools.jar;D:\Program Files\apache-tomcat-5.5.12\common\lib\servlet-api.jar;D:\Program Files\apache-tomcat-5.5.12\webapps\part1\lib\*.jar;

even though i h'v placed the commons-httpclient.jar in the lib folder as mentioned by some forums i'm getting the same error, any one plz guide
me for my next step in hibernate.

thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 14, 2006 6:28 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Does <dir>\*.jar work in a classpath? I use <dir>, no *.jar, and it works.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 15, 2006 3:40 am 
Newbie

Joined: Tue Mar 14, 2006 9:44 am
Posts: 3
Hello friends,
I h'v rectified that error by including the jar file name in my classpath in batch file.
however then i got the following new error, i struggled a lot to solve it myself but i can't, plz help me to solve the problem

Error Notification:


D:\Program Files\apache-tomcat-5.5.12\webapps\part1>java -classpath .\lib\hibernate3.jar;.\lib\commons-logging-1.0.4.jar;.\lib\commons-httpclient.jar;.\lib\log4j-1.2.9.jar;.\lib\jta.jar;.\lib\antlr-2.7.4.jar.\lib\commons-logging-1.0.4.jar;.\lib\hsqldb.jar;.\lib\cglib-full-2.0.2.jar;.\lib\commons-collections-2.1.1.jar;.\lib\dom4j-1.5.2.jar;.\lib\jdbc2_0-stdext.jar;.\bin de.gloegl.road2hibernate.EventManager
INFO - Hibernate 3.0rc1
INFO - hibernate.properties not found
INFO - using CGLIB reflection optimizer
INFO - using JDK 1.4 java.sql.Timestamp handling
INFO - Mapping resource: de/gloegl/road2hibernate/Event.hbm.xml
INFO - Mapping class: de.gloegl.road2hibernate.Event -> events
INFO - processing extends queue
INFO - processing collection mappings
INFO - processing association property references
INFO - processing foreign key constraints
Initial SessionFactory creation failed.org.hibernate.HibernateException: The dia
lect was not set. Set the property hibernate.dialect.

Exception in thread "main" java.lang.ExceptionInInitializerError
at de.gloegl.road2hibernate.HibernateUtil.<clinit>(HibernateUtil.java:27
)
at de.gloegl.road2hibernate.EventManager.main(EventManager.java:12)
Caused by: org.hibernate.HibernateException: The dialect was not set. Set the pr
operty hibernate.dialect.
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:474)
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:496)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:
51)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1497
)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1041)
at de.gloegl.road2hibernate.HibernateUtil.<clinit>(HibernateUtil.java:21
)
... 1 more

This is my hibernate.cfg.xml file

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="transaction.factory_class">
org.hibernate.transaction.JDBCTransactionFactory
</property>
<property name="hibernate.cache.provider_class">
org.hibernate.cache.HashtableCacheProvider
</property>
<property name="hibernate.hbm2ddl.auto">update</property>

<mapping resource="de/gloegl/road2hibernate/Event.hbm.xml"/>

</session-factory>

</hibernate-configuration>


Note : i tried even changing dialect to hibernate.dialect and removed hibernate. but problem still the same...
thanks in advance...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 15, 2006 5:35 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
In Hibernate 3, hibernate.dialect is the name of the property. However, I see in your stack trace that Dialect.getDialect is called, and that's from way back in HIbernate 2 days. In hibernate 3, DialectFactory.buildDialect is used instead. This suggests to me that you're using Hibernate 2 with an Hibernate 3 config file. Can you check this, and if that's the case, match up your config file and hibernate version?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 1:34 am 
Newbie

Joined: Tue Mar 14, 2006 9:44 am
Posts: 3
i'm using Hibernate3.1 only, could u tell me how to know the version of the configuration file, how to create different configuration files for different versions. For verification i attach my java file

package de.gloegl.road2hibernate;

import org.apache.commons.logging.*;
import org.hibernate.*;
import org.hibernate.cfg.*;

public class HibernateUtil {

private static final SessionFactory sessionFactory;

static {
try {

// Create the SessionFactory
Configuration cfg = new Configuration();
cfg.addResource("de/gloegl/road2hibernate/Event.hbm.xml");
cfg.setProperties( System.getProperties() );
sessionFactory = cfg.buildSessionFactory();

} catch (Throwable 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 final ThreadLocal session = new ThreadLocal();

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();
session.set(s);
}
return s;
}

public static void closeSession() throws HibernateException {
Session s = (Session) session.get();
session.set(null);
if (s != null)
s.close();
}
}

thanks in advance...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 5:05 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
I knew that you are using version 3+ becasue of this line from your config file:
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

I followed your stack trace through the various versions of Hibernate source code that I have on my local machine, and I note that your stack trace matches more closely with code from v2.1 than code from either v3.0.5 or v3.1.1. I didn't find an exact match, so whatever version you're using isn't on my machine.

The two things I recommend doing are
- ensuring that you're using the Hibernate3 properties (i.e. hibernate.dialect)
- ensuring that Hibernate.jar (or Hibernate2.jar) is removed from your classpath, leaving only HIbernate3.jar.


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