Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

New to hibernate .Error in executing my first program

 
sreenivas jeenor
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Here is compilation error that i am geeting.please solve my problem
i am using Hibernate 3.1 rc2

Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheE
xception
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
at java.lang.Class.getConstructor0(Class.java:2640)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at org.hibernate.cfg.SettingsFactory.createCacheProvider(SettingsFactory
.java:327)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:
219)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1823
)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1143)
at FirstExample.main(FirstExample.java:22)
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post your hibernate.cfg.xml? Looks like it contains reference to the earlier version of EHCache.
 
sreenivas jeenor
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jai,

here is the hibernate configuration file

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

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/hibernatetutorial</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping resource="contact.hbm.xml"/>
</session-factory>
</hibernate-configuration>
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting, the hibernate.cfg.xml doesnt have any reference to the cache provider. But the exception stacktrace shows that while the session factory is being built, the cache provider is being configured. Are you sure, this is the hibernate.cfg.xml that is being refered by Hibernate? Is there any hibernate.properties in your classpath, which might be containing references to the cache provider?
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!