-->
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: problem using EntityManager (JDBC Driver class not found)
PostPosted: Mon Jul 04, 2005 8:43 am 
Beginner
Beginner

Joined: Mon Jun 06, 2005 4:23 am
Posts: 41
Location: Hagenberg, AUSTRIA
hi!

i want to use hibernate, ejb3 and the entitymanager, but i got the exception displayed below. i get the exception when executing the following code in my main-method (exactly when calling createEntityMangerFactory):
Code:
   public static void main (String[] args) {
      
      // Use persistence.xml configuration
      EntityManagerFactory emf = Persistence.createEntityManagerFactory("IngresManager");
      EntityManager em = emf.createEntityManager(); // Retrieve a transactional-scoped entity manager
      //Work with the EM

      
      
      em.close();
      emf.close(); //close at application end   
   }


i know this is a simple problem, but i don't know where i have to put my jdbc-driver (= edbc.jar from ingres database) that hibernate can use it.

my folder structure is as follows:

DipasNgHibernate (Eclipse Project)
|
- src (hibernate.cfg.xml and source-files)
  |
  - META-INF (including persistence.xml)
- bin
- lib (with all the hibernate3 and related libs plus edbc.jar)



any hints are appreciated.

regards
patrik

my environment:
eclipse 3.1rc4, jdk1.5

Hibernate version:
3.1alpha1, the latest annotations (3.1beta3) and latest entity-manager (3.1beta1)

persistence.xml from META-INF
Code:
<?xml version="1.0" encoding="UTF-8"?>
<entity-manager>
   <name>IngresManager</name>
   <provider>org.hibernate.ejb.HibernatePersistence</provider>
   <class>ams.ingres.PvStamp</class>
   <class>ams.ingres.PvFamip</class>
   <properties>
        <property name="hibernate.connection.username">ingres</property>
        <property name="hibernate.connection.password">ingres</property>
        <property name="hibernate.dialect">org.hibernate.dialect.IngresDialect</property>
        <property name="hibernate.connection.url">jdbc:edbc://192.168.193.132:21071/dipasdem</property>
        <property name="hibernate.connection.driver_class">ca.edbc.jdbc.EdbcDriver</property>
      <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
   </properties>
</entity-manager>



Full stack trace of any exception that occurs:
Code:
FATAL DriverManagerConnectionProvider:65 - JDBC Driver class not found:
java.lang.ClassNotFoundException:
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Unknown Source)
   at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:109)
   at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:61)
   at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:80)
   at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:362)
   at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:60)
   at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1429)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:980)
   at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:182)
   at org.hibernate.ejb.HibernatePersistence.createFactory(HibernatePersistence.java:77)
   at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:93)
   at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:42)
   at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:29)
   at ams.hibernate.PvStampManager.main(PvStampManager.java:12)

Name and version of the database you are using:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 04, 2005 9:56 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Download CaveatEmptor and start from there: http://caveatemptor.hibernate.org/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 05, 2005 1:44 am 
Beginner
Beginner

Joined: Mon Jun 06, 2005 4:23 am
Posts: 41
Location: Hagenberg, AUSTRIA
the caveatemptor sample mentions that i should copy my jdbc-driver into the lib-directory. i've already done that and i'm still receiving the fatal error "JDBC Driver class not found" as already described in my posting before.

what else can i try?

regards
patrik


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 05, 2005 4:05 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Use HSQL DB that comes bundled with CaveatEmptor. It runs out of the box. Start from there...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 05, 2005 8:50 am 
Beginner
Beginner

Joined: Mon Jun 06, 2005 4:23 am
Posts: 41
Location: Hagenberg, AUSTRIA
i've already tried that, it works fine, and now i want to go one step further.

i figured out that the <property name="hibernate.connection.driver_class">ca.edbc.jdbc.EdbcDriver</property> in the persistence.xml file won't work for me. this causes the fatal error (i guess).

i changed the whole properties in persistence.xml to the one following:
<property name="hibernate.ejb.cfgfile" value="hibernate.cfg.xml"/>

this link to the hibernate.cfg.xml file works in my case, but i've no idea where's the difference between the config in the persistence.xml and the hibernate.cfg.xml. they use exactly the same properties.

maybe a bug?

regards
patrik


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 05, 2005 8:52 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This hasn't been finalized when the EntityManager was released. You need the CVS version to get Hibernate properties in the persistence.xml. AFAIK this still is moving and can change any day again.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 05, 2005 9:19 am 
Beginner
Beginner

Joined: Mon Jun 06, 2005 4:23 am
Posts: 41
Location: Hagenberg, AUSTRIA
ok, good to know!
thanks for the quick response and your hints.

regards
patrik


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2005 3:36 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
MistaMoasn wrote:
i figured out that the <property name="hibernate.connection.driver_class">ca.edbc.jdbc.EdbcDriver</property> in the persistence.xml file won't work for me. this causes the fatal error (i guess).

This is supposed to work, even with the beta1 version. But that's true that the persistence.xml processing is a bit "fresh".

_________________
Emmanuel


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.