-->
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.  [ 2 posts ] 
Author Message
 Post subject: Could not initialize class org.hibernate.cfg.Configuration
PostPosted: Wed Dec 24, 2008 2:52 am 
Newbie

Joined: Wed Dec 24, 2008 2:21 am
Posts: 2
Hi all,

I am getting this exception after I try to load my app. I have the necessary hibernate jars in my classpath namely hibernate3.jar, hibernate-annotations.jar, hibernate-entitymanager.jar and hibernate-commons-annotations.jar. I have configured hibernate through spring. Here is my spring config:

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/db"></property>
<property name="username" value="abc"></property>
<property name="password" value="abc123"></property>
</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="annotatedClasses">
<list>
<value>com.gex.domain.NewAccount</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
</bean>

I also tried using a hibernate.properties file with the database settings but that did not help either.

The exception trace is:

Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/gex-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.Configuration

Any help with this issue will be greatly appreciated. Thanks in advance.


Top
 Profile  
 
 Post subject: Configuration construction fails - or driver not found
PostPosted: Mon Mar 02, 2009 6:15 pm 
Newbie

Joined: Mon Mar 02, 2009 3:26 pm
Posts: 1
I was getting the same problem you describe.


The error is very cryptic. Surprising given the wide acceptance of Hibernate that it would have some sort of static method on Configuration to give you the configuration and a meaningful exception if the dependencies for a Configuration cannot be loaded or accessed.

Also helpful would be a clear identification in the manifest of the required apis and versions for the implementation of hibernate you are using.

Was scratching my head as I new the jdbc driver I was looking for was in my classpath as was hibernate3.jar the commons jars, and some of the others.

It is not the jars you identify. You need some additional dependencies for hibernate in your class path.


Try adding the following jars that are listed in the reference document:
Hibernate Reference Documentation vs: 3.2.2 on page 10.


antlr.jar
cglib.jar
asm.jar
asm-attr.jar
commons-collections.jar
commons-logging.jar
hibernate3.jar
jta.jar
dom4j.jar
log4j.jar


I searched the hibernate site and found http://www.hibernate.org/27.html
and the section * Projects Used By Hibernate. With links to the mentioned resources.


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