-->
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.  [ 3 posts ] 
Author Message
 Post subject: problem with the configure()
PostPosted: Thu Aug 17, 2006 3:22 am 
Newbie

Joined: Thu Aug 17, 2006 2:49 am
Posts: 2
Hibernate version: 3.1
Name and version of the database you are using: MySQL Server 5.0

Hi from newbie ;)

I'm occuring a problem with the Configuration class i think at the configure() method. Simply i just can't build the SessionFactory. What i know is that the program tries to connect to the DB cause my firewall detects a connection on the localhost. Here's the code.

Code:
package pkg;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class GoDB
{
   public static void main(String[] args)
   {
       Session session = null;

       try
       {     Configuration cfg = new Configuration();
          cfg.configure();
          SessionFactory sessionFactory = cfg.buildSessionFactory();
          session = sessionFactory.openSession();
          org.hibernate.Transaction tx = session.beginTransaction();

          Message msg = new Message();
          msg.setId(4);
          msg.setText("some txt");
          session.save(msg);
          System.out.println("done");
           tx.commit();
           session.flush();
           session.close();
       }
       catch(Exception e)
       {
         System.out.println(e.getMessage());
       }
       finally
       {
          // session.flush();
          // session.close();
       }
   }
}


This is my hibernate.cfg.xml file.

Code:
<?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:3306/message</property>
       <property name="hibernate.connection.username">root</property>
         <property name="hibernate.connection.password">xxx</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="pkg/message.hbm.xml"/>
   </session-factory>
</hibernate-configuration>


Message that i get from eclipse

Full stack trace of any exception that occurs:
Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
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:1881)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
at pkg.GoDB.main(GoDB.java:16)



I would be grateful for any help.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 17, 2006 3:31 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
you are missing ehcache.jar in your classpath

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 17, 2006 3:42 am 
Newbie

Joined: Thu Aug 17, 2006 2:49 am
Posts: 2
thx it helped :)


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