-->
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.  [ 3 posts ] 
Author Message
 Post subject: Classloader issue when running in separate eclipse plugins
PostPosted: Tue Sep 26, 2006 5:38 pm 
Newbie

Joined: Tue Sep 26, 2006 11:54 am
Posts: 10
Hibernate version: 3.2 RC4

Mapping documents: none, using programatic API

I am attempting to create an EntityManagerFactory using a programatically created EJB3Configuration with device driver managernconnection info.
This is done in the context of eclipse:

1- one plugin for all of hibernate
2- one plugin for my database driver (hsqldb)
3- one plugin that depends on both to create the entity manager.

Here is the code of my entity manager creation in plugin 3:

Code:
   
    Class.forName(org.hsqldb.jdbcDriver.class.getName());
    // Configure our EJB3 EntityManagerFactory
    Ejb3Configuration ejbconf = new Ejb3Configuration();
    ejbconf.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
    ejbconf.setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
    ejbconf.setProperty("hibernate.connection.url", "jdbc:hsqldb:data/example");
    ejbconf.setProperty("hibernate.connection.username", "sa");
    ejbconf.setProperty("hibernate.connection.password", "");
    ejbconf.setProperty("hibernate.max_fetch_depth", "3");
    ejbconf.setProperty("hibernate.hbm2ddl.auto", "create");
    ejbconf.setProperty("hibernate.show_sql", "true");
    ejbconf.addAnnotatedClass(LogRecord.class);
    emf = ejbconf.buildEntityManagerFactory();


Executing this code, I get this exception at the last line:

Code:
javax.persistence.PersistenceException: org.hibernate.HibernateException: JDBC Driver class not found: org.hsqldb.jdbcDriver
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:695)
   at com.hhh.logging.hibernate.test.TestDBHandler.setUp(TestDBHandler.java:55)
   at junit.framework.TestCase.runBare(TestCase.java:128)
   at junit.framework.TestResult$1.protect(TestResult.java:110)
   at junit.framework.TestResult.runProtected(TestResult.java:128)
   at junit.framework.TestResult.run(TestResult.java:113)
   at junit.framework.TestCase.run(TestCase.java:120)
   at junit.framework.TestSuite.runTest(TestSuite.java:228)
   at junit.framework.TestSuite.run(TestSuite.java:223)
   at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
   at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:58)
   at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:24)
   at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
   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:585)
   at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
   at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
   at org.eclipse.core.launcher.Main.run(Main.java:977)
   at org.eclipse.core.launcher.Main.main(Main.java:952)
Caused by: org.hibernate.HibernateException: JDBC Driver class not found: org.hsqldb.jdbcDriver
   at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:66)
   at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
   at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
   at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
   at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216)
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:688)
   ... 29 more
Caused by: java.lang.ClassNotFoundException: org.hsqldb.jdbcDriver
   at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:407)
   at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:352)
   at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:83)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
   at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:164)
   at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
   at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:61)
   ... 35 more


The issue is caused by Eclipse that does not give access to hibernate (which runs in its own plugin) to access the class located in the hsqldb plugin since the hibernate plugin does not explicitely depend on this hsqldb plugin. This seems to be cause by the way the ReflectHelper class loads the device driver class.

I am waiting for feedback from eclipse as well but was wondering if anyone has an idea on how to fix this from here?

--
Michel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 26, 2006 9:38 pm 
Senior
Senior

Joined: Sun Jun 04, 2006 1:58 am
Posts: 136
1.did you export the all the packages ... ??
2.If yes you might have to use eclipe buddy classloading mechanism ...
as described as hibernate plugin would both be consumer and supplier of servcies

you can find more about buddy classloading here ...

http://www.eclipsezone.com/articles/eclipse-vms/

_________________
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 26, 2006 10:31 pm 
Newbie

Joined: Tue Sep 26, 2006 11:54 am
Posts: 10
Yes, buddy classloading was the way to go.


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