-->
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.  [ 8 posts ] 
Author Message
 Post subject: Problems with 'new Configuration()'
PostPosted: Thu Jun 09, 2005 9:39 am 
Newbie

Joined: Thu Jun 09, 2005 9:07 am
Posts: 13
Hello,

I'm a new user, I use Hibernate 3.0, and I'm trying to make the Hibernate setup(P13 in the doc) and I get the following error message:

Initial sessionFactory creation failed.java.lang.NoClassDefFoundError: javax/transaction/Synchronization

The error is when the program is trying to create a new Configuration() (I've splited the sessionFactory declaration to check where the problem happens but otherwise, the code is the same as HibernateUtil).

I'm use jsf faces from Exadel, I have a save method in my bean which calls a save method in a manager which uses HibernateUtil, here's the code of the manager class:
import java.util.Iterator;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

/*
* Created on 2005-06-08
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/

/**
* @author eplante
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/

public class CatManager {
public static void save(Cat objCat){
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();

session.save(objCat);
tx.commit();
HibernateUtil.closeSession();
}

public static Cat getCat(String catName){
Cat objCat = new Cat();
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();

Query query = session.createQuery("select c from Cat as c where c.name = :name");
query.setString("name", catName);
for (Iterator it = query.iterate();it.hasNext();){
objCat = (Cat) it.next();
}
tx.commit();
return objCat;
}

}

I'm using MySql so the hibernate.cfg.xml looks like this:
<?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="connection.drivers_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/animal</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">update</property>

<!-- Mapping files-->
<mapping resource="Cat.hbm.xml"/>
</session-factory>
</hibernate-configuration>


the class mapped into Cat.hbm.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Cat" table="cat">
<id name="id" type="integer">
<column name="id" not-null="true" sql-type="integer"/>
<generator class="native"/>
</id>
<property name="name" type="string">
<column length="16" name="name" not-null="true" sql-type="VARCHAR"/>
</property>
<property name="sex" type="character">
<column length="1" name="sex" sql-type="VARCHAR"/>
</property>
<property name="weight" type="float">
<column name="weight" sql-type="REAL"/>
</property>
</class>
</hibernate-mapping>

I have no idea why it doesn't work, anyone has an idea why?

thanks


Top
 Profile  
 
 Post subject: Re: Problems with 'new Configuration()'
PostPosted: Thu Jun 09, 2005 9:42 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Cosmos wrote:
Hello,

I'm a new user, I use Hibernate 3.0, and I'm trying to make the Hibernate setup(P13 in the doc) and I get the following error message:

Initial sessionFactory creation failed.java.lang.NoClassDefFoundError: javax/transaction/Synchronization

The error is when the program is trying to create a new Configuration() (I've splited the sessionFactory declaration to check where the problem happens but otherwise, the code is the same as HibernateUtil).

...

I have no idea why it doesn't work, anyone has an idea why?

thanks


you need the jta.jar in your classpath. Make sure you read the docs for all required libraries. There is a _README.TXT file in the lib directory of the hibernate distribution.


Top
 Profile  
 
 Post subject: Re: Problems with 'new Configuration()'
PostPosted: Thu Jun 09, 2005 1:38 pm 
Newbie

Joined: Thu Jun 09, 2005 9:07 am
Posts: 13
Quote:
you need the jta.jar in your classpath. Make sure you read the docs for all required libraries. There is a _README.TXT file in the lib directory of the hibernate distribution.


I found the readme to be confusing but I took every jar listed in the file and added them into my project and now the problem I get when I pass the new Configuration() is the rt.jar has no source attachement but I have no idea where or what is that rt.jar.

Any idea what the problem is?

Thanks


Top
 Profile  
 
 Post subject: Re: Problems with 'new Configuration()'
PostPosted: Thu Jun 09, 2005 1:46 pm 
Newbie

Joined: Thu Jun 09, 2005 9:07 am
Posts: 13
Cosmos wrote:
Quote:
you need the jta.jar in your classpath. Make sure you read the docs for all required libraries. There is a _README.TXT file in the lib directory of the hibernate distribution.


I found the readme to be confusing but I took every jar listed in the file and added them into my project and now the problem I get when I pass the new Configuration() is the rt.jar has no source attachement but I have no idea where or what is that rt.jar.

Any idea what the problem is?

Thanks


I noticed that Hibernate3.jar wasn't in the readme but it's obviously needed, are there any conflicts between some jar in the readme and those that could have been included in the hibernate3.jar when it was built?

Thanks


Top
 Profile  
 
 Post subject: Re: Problems with 'new Configuration()'
PostPosted: Thu Jun 09, 2005 2:11 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Cosmos wrote:
Cosmos wrote:
Quote:
you need the jta.jar in your classpath. Make sure you read the docs for all required libraries. There is a _README.TXT file in the lib directory of the hibernate distribution.


I found the readme to be confusing but I took every jar listed in the file and added them into my project and now the problem I get when I pass the new Configuration() is the rt.jar has no source attachement but I have no idea where or what is that rt.jar.

Any idea what the problem is?

Thanks


I noticed that Hibernate3.jar wasn't in the readme but it's obviously needed, are there any conflicts between some jar in the readme and those that could have been included in the hibernate3.jar when it was built?

Thanks

Look at the hibernate3.jar. Nothing is in it except org.hibernate.** code.


Top
 Profile  
 
 Post subject: Re: Problems with 'new Configuration()'
PostPosted: Thu Jun 09, 2005 2:17 pm 
Newbie

Joined: Thu Jun 09, 2005 9:07 am
Posts: 13
pksiv wrote:
Cosmos wrote:
Cosmos wrote:
Quote:
you need the jta.jar in your classpath. Make sure you read the docs for all required libraries. There is a _README.TXT file in the lib directory of the hibernate distribution.


I found the readme to be confusing but I took every jar listed in the file and added them into my project and now the problem I get when I pass the new Configuration() is the rt.jar has no source attachement but I have no idea where or what is that rt.jar.

Any idea what the problem is?

Thanks


I noticed that Hibernate3.jar wasn't in the readme but it's obviously needed, are there any conflicts between some jar in the readme and those that could have been included in the hibernate3.jar when it was built?

Thanks

Look at the hibernate3.jar. Nothing is in it except org.hibernate.** code.


Ok. Any idea what that rt.jar has no source attachement message is?


Top
 Profile  
 
 Post subject: Re: Problems with 'new Configuration()'
PostPosted: Thu Jun 09, 2005 2:26 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Cosmos wrote:
pksiv wrote:
Cosmos wrote:
Cosmos wrote:
Quote:
you need the jta.jar in your classpath. Make sure you read the docs for all required libraries. There is a _README.TXT file in the lib directory of the hibernate distribution.


I found the readme to be confusing but I took every jar listed in the file and added them into my project and now the problem I get when I pass the new Configuration() is the rt.jar has no source attachement but I have no idea where or what is that rt.jar.

Any idea what the problem is?

Thanks


I noticed that Hibernate3.jar wasn't in the readme but it's obviously needed, are there any conflicts between some jar in the readme and those that could have been included in the hibernate3.jar when it was built?

Thanks

Look at the hibernate3.jar. Nothing is in it except org.hibernate.** code.


Ok. Any idea what that rt.jar has no source attachement message is?


rt.jar contains the Java runtime classes.... I would be suprised if a message complaining about "no source attachment" was from hibernate. More likely from a debugger.


Top
 Profile  
 
 Post subject: Re: Problems with 'new Configuration()'
PostPosted: Thu Jun 09, 2005 2:42 pm 
Newbie

Joined: Thu Jun 09, 2005 9:07 am
Posts: 13
I managed to get pass that rt.jar problem but I have trouble with Tomcat's listener that crashes gives an error when it starts and it seems to be a cause of new Configuration from working properly. Dunno why it does that though but that's a problem beyond the scope of this topic.

Thanks for your help


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