Bonjour,
Je suis débutant et j'ai des problèmes pour la mise en oeuvre d'hibernate3.
Contexte technique : IRWD, Oracle 9.2.0.1.0, WAS 6 Express, JRE 1.5.0_05
Hibernate version: 3.1 rc3
hibernate3.jar
ehcache-1.1.jar
jgroups-2.2.7.jar
jta.jar
commons-logging-1.0.4.jar
asm-attrs.jar
dom4j-1.6.1.jar
antlr-2.7-5H3.jar
cglib-2.1.2.jar
asm.jar
jdbc2_0-stdext.jar
commons-collections-2.1.1.jar
CLASSE12.ZIP (Oracle JDBC Driver version - 9.0.2.0.0)
Mapping documents:
<?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 >
<!-- local connection properties -->
<property name="hibernate.connection.url">jdbc:oracle:thin:@wkoracle:1521:negoce</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.username">negoce</property>
<property name="hibernate.connection.password">negoce</property>
<!-- property name="hibernate.connection.pool_size"></property -->
<!-- dialect for Oracle 9 -->
<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.use_outer_join">true</property>
<!--
<property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>
-->
<property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
<mapping resource="Devise.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Fichier de mapping :
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.cylande.devise.bean.Devise" table="DEVISES">
<id name="id" column="DEVISE_ID">
<generator class="increment" />
</id>
<property name="code" column="CODE" />
<property name="taux" column="TAUX_CONVERSION" />
</class>
</hibernate-mapping>
Code :
package com.cylande.mapping;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import com.cylande.devise.bean.Devise;
public class HibernateUtil {
private static final SessionFactory sessionFactory;
public static final ThreadLocal session = new ThreadLocal();
static {
try {
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (HibernateException ex) {
throw new RuntimeException("Problème de configuration Hibernate : " + ex.getMessage(), ex);
}
}
public static Session getSession() throws HibernateException {
Session s = (Session) session.get();
if (s == null) {
s = sessionFactory.openSession();
session.set(s);
}
return s;
}
public static void closeSession() throws HibernateException {
Session s = (Session) session.get();
session.set(null);
if (s != null)
s.close();
}
public static void main(String[] args) throws Exception {
try {
Session session = HibernateUtil.getSession();
Transaction tx = session.beginTransaction();
Devise devise = (Devise) session.load(Devise.class, new Integer(2));
System.out.println(devise.getTaux());
session.close();
} catch (Exception ex) {
System.err.println(ex.getMessage());
}
}
}
Full stack trace of any exception that occurs:
9 déc. 2005 10:53:26 org.hibernate.cfg.Environment
INFO: Hibernate 3.1 rc3
9 déc. 2005 10:53:26 org.hibernate.cfg.Environment
INFO: hibernate.properties not found
9 déc. 2005 10:53:26 org.hibernate.cfg.Environment
INFO: using CGLIB reflection optimizer
9 déc. 2005 10:53:26 org.hibernate.cfg.Environment
INFO: using JDK 1.4 java.sql.Timestamp handling
9 déc. 2005 10:53:26 org.hibernate.cfg.Configuration
INFO: configuring from resource: /hibernate.cfg.xml
9 déc. 2005 10:53:26 org.hibernate.cfg.Configuration
INFO: Configuration resource: /hibernate.cfg.xml
9 déc. 2005 10:53:27 org.hibernate.cfg.Configuration
INFO: Reading mappings from resource: Devise.hbm.xml
9 déc. 2005 10:53:27 org.hibernate.cfg.HbmBinder
INFO: Mapping class: com.cylande.devise.bean.Devise -> DEVISES
9 déc. 2005 10:53:27 org.hibernate.cfg.Configuration
INFO: Configured SessionFactory: null
9 déc. 2005 10:53:27 org.hibernate.cfg.Configuration
INFO: processing extends queue
9 déc. 2005 10:53:27 org.hibernate.cfg.Configuration
INFO: processing collection mappings
9 déc. 2005 10:53:27 org.hibernate.cfg.Configuration
INFO: processing association property references
9 déc. 2005 10:53:27 org.hibernate.cfg.Configuration
INFO: processing foreign key constraints
Chargement de la classe java impossible. java.lang.ExceptionInInitializerError
En enlevant la référence au fichier Devise.hbm.xml dans la config :
9 déc. 2005 10:35:54 org.hibernate.cfg.Environment
INFO: Hibernate 3.1 rc3
9 déc. 2005 10:35:55 org.hibernate.cfg.Environment
INFO: hibernate.properties not found
9 déc. 2005 10:35:55 org.hibernate.cfg.Environment
INFO: using CGLIB reflection optimizer
9 déc. 2005 10:35:55 org.hibernate.cfg.Environment
INFO: using JDK 1.4 java.sql.Timestamp handling
9 déc. 2005 10:35:55 org.hibernate.cfg.Configuration
INFO: configuring from resource: /hibernate.cfg.xml
9 déc. 2005 10:35:55 org.hibernate.cfg.Configuration
INFO: Configuration resource: /hibernate.cfg.xml
9 déc. 2005 10:35:55 org.hibernate.cfg.Configuration
INFO: Configured SessionFactory: null
9 déc. 2005 10:35:55 org.hibernate.cfg.Configuration
INFO: processing extends queue
9 déc. 2005 10:35:55 org.hibernate.cfg.Configuration
INFO: processing collection mappings
9 déc. 2005 10:35:55 org.hibernate.cfg.Configuration
INFO: processing association property references
9 déc. 2005 10:35:55 org.hibernate.cfg.Configuration
INFO: processing foreign key constraints
9 déc. 2005 10:35:55 org.hibernate.connection.DriverManagerConnectionProvider
INFO: Using Hibernate built-in connection pool (not for production use!)
9 déc. 2005 10:35:55 org.hibernate.connection.DriverManagerConnectionProvider
INFO: Hibernate connection pool size: 20
9 déc. 2005 10:35:55 org.hibernate.connection.DriverManagerConnectionProvider
INFO: autocommit mode: false
9 déc. 2005 10:35:55 org.hibernate.connection.DriverManagerConnectionProvider
INFO: using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@wkoracle:1521:negoce
9 déc. 2005 10:35:55 org.hibernate.connection.DriverManagerConnectionProvider
INFO: connection properties: {user=negoce, password=****}
9 déc. 2005 10:35:56 org.hibernate.cfg.SettingsFactory
INFO: RDBMS: Oracle, version: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
9 déc. 2005 10:35:56 org.hibernate.cfg.SettingsFactory
INFO: JDBC driver: Oracle JDBC driver, version: 9.2.0.3.0
Chargement de la classe java impossible. java.lang.ExceptionInInitializerError
Qu'est ce que je n'ai pas compris ? Merci de bien vouloir m'aider...
|