-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate config problem
PostPosted: Mon Mar 22, 2010 5:55 am 
Newbie

Joined: Mon Mar 22, 2010 5:43 am
Posts: 3
Hi,

I tried to insert in my databases some datas, but i had this error message :
Code:
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: javax/transaction/SystemException
Exception in thread "main" java.lang.ExceptionInInitializerError
   at Utils.HibernateUtil.buildSessionFactory(HibernateUtil.java:17)
   at Utils.HibernateUtil.<clinit>(HibernateUtil.java:8)
   at Manips.Ajout.Ajout_Reservation(Ajout.java:11)
   at Manips.test.main(test.java:7)
Caused by: java.lang.NoClassDefFoundError: javax/transaction/SystemException
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1055)
   at Utils.HibernateUtil.buildSessionFactory(HibernateUtil.java:13)
   ... 3 more
Caused by: java.lang.ClassNotFoundException: javax.transaction.SystemException
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClassInternal(Unknown Source)


hibernate Version : 3.0.1

HibernateUtil.java :
Quote:
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {

private static final SessionFactory sessionFactory = buildSessionFactory();

private static SessionFactory buildSessionFactory() {
try {
// Create the SessionFactory from hibernate.cfg.xml
return new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}

public static SessionFactory getSessionFactory() {
return sessionFactory;
}

}


my hibernate.cfg.xml :
Quote:
<?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>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">facenet</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/facenet</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.DB2Dialect</property>

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

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


<property name="hibernate.show_sql">false</property>
<property name="hibernate.use_outer_join">true</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>-->

<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>

<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">none</property>

<mapping resource="Party.hbm.xml"/>
<mapping resource="Userlogin.hbm.xml"/>
<mapping resource="PartyGroup.hbm.xml"/>
<mapping resource="Person.hbm.xml"/>
<mapping resource="PartyRole.hbm.xml"/>
<mapping resource="Campany.hbm.xml"/>
<!--<mapping resource="Provider.hbm.xml"/>-->
<mapping resource="PartyClassification.hbm.xml"/>
<mapping resource="PartyClassificationGroup.hbm.xml"/>
<mapping resource="RoleType.hbm.xml"/>
<mapping resource="Marital.hbm.xml"/>
</session-factory>
</hibernate-configuration>


I would like to know where is my problem (config problem?)

Thks.


Top
 Profile  
 
 Post subject: Re: Hibernate config problem
PostPosted: Mon Mar 22, 2010 6:35 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Hi,

you must include jta-1.1.jar into your classpath.
(jta-1.1.jar is usually distributed under directory lib/required)


Top
 Profile  
 
 Post subject: Re: Hibernate config problem
PostPosted: Mon Mar 22, 2010 7:19 am 
Newbie

Joined: Mon Mar 22, 2010 5:43 am
Posts: 3
pb00067 wrote:
Hi,

you must include jta-1.1.jar into your classpath.
(jta-1.1.jar is usually distributed under directory lib/required)


I use hibernate in a maven project; So, i add a dependancy tag in my pom.xml (in bold).

my pom.xml :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>assistantfacenet</groupId>
<artifactId>assistantfacenet</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>assistantfacenet</name>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>

<!-- MySQL database driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>

<!-- Hibernate core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.0.1</version>
<exclusions>
<exclusion>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
</exclusion>
</exclusions>

</dependency>

<!-- Hibernate annotation -->
<dependency>
<groupId>hibernate-annotations</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.3.0.GA</version>
</dependency>

<dependency>
<groupId>hibernate-commons-annotations</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.0.0.GA</version>
</dependency>


<!-- Hibernate library dependecy start -->
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>

<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>

<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>

<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
</dependency>
<!-- Hibernate library dependecy end -->


<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
</dependency>
<dependency>
<groupId>ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
</project>


but i had the same error message.

Thks.


Top
 Profile  
 
 Post subject: Re: Hibernate config problem
PostPosted: Mon Mar 22, 2010 8:45 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
i add a dependancy tag in my pom.xml ... but i had the same error message.


I'm not familiar with maven because I don't use it.
Anyway: the NoClassDefFoundError: javax/transaction/SystemException definitely
comes from the fact that jta.jar is missing in the runtime java classpath.
Please check if the path (and the syntax) to the jta artifact is correctly set.
Maybe there's also a kind of verbose option you can enbable for maven.


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