-->
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.  [ 2 posts ] 
Author Message
 Post subject: [Débutant] - Problème d'accès à une base Oracle 9i
PostPosted: Fri Dec 09, 2005 6:00 am 
Newbie

Joined: Fri Dec 09, 2005 5:22 am
Posts: 2
Location: Belfort
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...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 13, 2005 6:21 am 
Newbie

Joined: Fri Dec 09, 2005 5:22 am
Posts: 2
Location: Belfort
Mon erreur vient du nom du Dialect dans le fichier de config d'hibernate :

il faut mettre org.hibernate.dialect.Oracle9Dialect et non

net.sf.hibernate.dialect.Oracle9Dialect

Attention aussi à la version du driver :

ojdbc14.jar pour un >= JDK 1.4
et classes12.zip pour un JDK inférieur


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