-->
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.  [ 1 post ] 
Author Message
 Post subject: Unable to use Derby with Hibernate
PostPosted: Sun Jul 15, 2012 10:18 pm 
Newbie

Joined: Sun Jul 15, 2012 7:57 am
Posts: 5
Hi everyone,

I am desperately trying to make hibernate work with Apache Derby plugin in my eclipse RCP project.

When I run the application i get an error saying unable to instantiate driver class file. The details are listed below.

Any help is much appreciated.

Here is my config file
Code:
<?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 name="mySessionFactory">
  <property name="hibernate.connection.driver_class">org.apache.derby.jdbc.EmbeddedDriver</property>
  <property name="hibernate.connection.url">jdbc:derby:/Users/Shashank/Desktop/rubrics/Rubrics/database/rubricsData</property>
  <property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
  <property name="hibernate.show_sql">true</property>
  <property name="hibernate.hbm2ddl.auto">update</property>
  <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
  <property name="hibernate.format_sql">false</property>
</session-factory>
</hibernate-configuration>


I have derby databases properly setup. I am also able to get access to the database using Hibernate console configuration in the Eclipse IDE.

But when I run the application I get the following errors:

Quote:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
JDBC Driver class not found: org.apache.derby.jdbc.EmbeddedDriver
!SESSION 2012-07-16 12:07:17.589 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_33
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments: -product Rubrics.product
Command-line arguments: -product Rubrics.product -data /Users/Shashank/Desktop/rubrics/../runtime-pc.product -dev file:/Users/Shashank/Desktop/rubrics/.metadata/.plugins/org.eclipse.pde.core/pc.product/dev.properties -os macosx -ws cocoa -arch x86_64 -consoleLog

!ENTRY org.eclipse.osgi 4 0 2012-07-16 12:07:19.075
!MESSAGE Application error
!STACK 1
java.lang.ExceptionInInitializerError
at rubrics.datatools.HibernateUtil.getSessionFactory(HibernateUtil.java:25)
at rubrics.RubricsApplication.start(RubricsApplication.java:44)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Caused by: org.hibernate.HibernateException: JDBC Driver class not found: org.apache.derby.jdbc.EmbeddedDriver
at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:123)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:143)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:84)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:438)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:91)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2159)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1383)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
at rubrics.datatools.HibernateUtil.getSessionFactory(HibernateUtil.java:19)
... 14 more
Caused by: java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:118)
... 23 more
An error has occurred. See the log file
/Users/Shashank/Desktop/runtime-pc.product/.metadata/.log.



Here is the code where the exceptions are generated:

Code:
package rubrics.datatools;


import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import rubrics.RubricsPlugin;
import org.hibernate.cfg.AnnotationConfiguration;

public class HibernateUtil {
   private static SessionFactory sessionFactory = null;
   
   
   public static SessionFactory getSessionFactory()
   {
      if(sessionFactory == null)
      {
         try {
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
            sessionFactory = new AnnotationConfiguration().configure(RubricsPlugin.hibernateCfgPath).buildSessionFactory();
         
         }
         catch (Throwable ex)
         {
            System.out.println(ex.getMessage());
            throw new ExceptionInInitializerError(ex);
         }
      }
      return sessionFactory;
   }
   
   

}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.