-->
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: Can't get first step Configuration cfg = new Configuration()
PostPosted: Sun May 28, 2006 11:47 pm 
Newbie

Joined: Sun May 28, 2006 11:35 pm
Posts: 3
I have the following method in my main application class:

118: public void testHibernate()
119: {
120: Configuration cfg = new Configuration();
121: cfg.addResource("golfbase/Courses");
122: cfg.setProperties(System.getProperties());
123: SessionFactory sf = cfg.buildSessionFactory();
124: Session session = sf.openSession();
125: session.close();
126: }

It keeps throwing the following exception on the very first line:

Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at golfbase.golfBase.testHibernate(golfBase.java:120)
at golfbase.golfBase.<init>(golfBase.java:51)
at golfbase.golfBase.main(golfBase.java:66)


I have followed all the information in Hibernate In Action and the sample code from the Hibernate 3.1 installation runs fine (build eg) so I know I have installed properly. I am using Eclipse and have added the hibernate3.jar, log4j-1.2.11.jar, and mysql-connector-java-3.1.12-bin.jar files to my project. My hibernate.cfg.xml file is as follows:

<?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>

<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/golf</property>
<property name="connection.username">XXXX</property>
<property name="connection.password">xxxx</property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>

<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>

<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>

<mapping resource="golfbase/Courses.hbm.xml"/>

</session-factory>

</hibernate-configuration>

Pretty basic, but it doesn't work. Any ideas? Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 29, 2006 12:17 am 
Newbie

Joined: Sun May 28, 2006 11:35 pm
Posts: 3
Ok, have some patience I'm new at this. Found I was missing lots of other jars (dom4j, commons-logging, commons-collections, cglib, asm). Added them and got a bit farther. Now I am getting the following when it tries to build a SessionFactory:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/transaction/Synchronization
at org.hibernate.impl.SessionFactoryImpl.buildCurrentSessionContext(SessionFactoryImpl.java:946)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:311)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at golfbase.golfBase.testHibernate(golfBase.java:122)
at golfbase.golfBase.<init>(golfBase.java:51)
at golfbase.golfBase.main(golfBase.java:66)

Looks like I'm missing some kind of java extension? I'm not using J2EE, just J2SE. Is that the problem?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 29, 2006 2:39 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi,

Looks like you don't have another jar in the classpath.

jta.jar

Add this and test it.

Note:javax/transaction/Synchronization is also available in the j2ee.jar, but there are few conflicts.

All the Best

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


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.