-->
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.  [ 5 posts ] 
Author Message
 Post subject: Problems with JUnit and CacheProvider
PostPosted: Tue Dec 23, 2003 9:10 am 
Newbie

Joined: Tue Nov 18, 2003 11:56 am
Posts: 16
I'm running Hibernate 2.1 and I'm having problems when I run tests using JUnit 3.8.1. I use the UI-test runner and I always get the following exception:

net.sf.hibernate.HibernateException: could not instantiate CacheProvider: net.sf.ehcache.hibernate.Provider
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:115)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1072)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:718)
at no.nr.pl.server.DatabaseManager.getSession(DatabaseManager.java:76)
(snip)

If I uncheck the "Reload classes every run" box it works fine. I have also tried to modify the excluded.properties inside junit.jar by adding net.sf.ehcache to it, but that doesn't help.

I don't have any setting for caching in hibernate.cfg.xml.

Any ideas on how I can fix this?

Thanks
Per Thomas


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 23, 2003 11:22 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
add ehcache in your CP

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 25, 2003 6:06 am 
Newbie

Joined: Tue Nov 18, 2003 11:56 am
Posts: 16
The ehcache.jar is already in the classpath when I start JUnit. I think the problem is the special JUnit classloader. When I disable it, the class is found. After reading the JUnit FAQ the problem should be solved by adding net.sf.ehcache.* to a list of excluded classes. But that doesn't work either.

Any other ideas?

Per Thomas


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 13, 2004 3:38 am 
Newbie

Joined: Tue Nov 18, 2003 11:56 am
Posts: 16
The problem solved itself by upgrading to Hibernate 2.1.1.

_________________
Thanks
Per Thomas


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 20, 2004 10:23 pm 
Beginner
Beginner

Joined: Sun Jun 06, 2004 10:13 am
Posts: 20
i'm getting this EXACT same problem, only in the latest hibernate version. My junit test is failing (see stack trace below) if i run it from ant, but if i run the test from my IDE or if i uncheck the 'reload classes every run' in junit, it passes. clearly this is some kind of crazy classloader problem. I have the ehchache.jar file in my CP, and i have updated the excluded.properties file in my junit jar. anyone got any other ideas? this is killing me since i know the test passes!

[junit] net.sf.hibernate.HibernateException: could not instantiate CacheProvider: net.sf.ehcache.hibernate.Provider
[junit] at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:133)
[junit] at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1132)
[junit] at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:766)
[junit] at store.HibernateProfileStore.initConfig(HibernateProfileStore.java:38)
[junit] at store.HibernateProfileStore.saveProfile(HibernateProfileStore.java:163)
[junit] at store.test.HibernateProfileStoreTest.testGetAndSave(HibernateProfileStoreTest.java:40)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] at java.lang.reflect.Method.invoke(Method.java:324)
[junit] at junit.framework.TestCase.runTest(TestCase.java:154)
[junit] at junit.framework.TestCase.runBare(TestCase.java:127)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:124)
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:118)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[junit] at junit.framework.TestSuite.run(TestSuite.java:203)
[junit] at junit.swingui.TestRunner$16.run(TestRunner.java:623)
[junit] Caused by: java.lang.ClassCastException
[junit] java.lang.NullPointerException
[junit] at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:130)
[junit] ... 18 more
[junit] at store.HibernateProfileStore.saveProfile(HibernateProfileStore.java:186)
[junit] at store.test.HibernateProfileStoreTest.testGetAndSave(HibernateProfileStoreTest.java:40)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] at java.lang.reflect.Method.invoke(Method.java:324)
[junit] at junit.framework.TestCase.runTest(TestCase.java:154)
[junit] at junit.framework.TestCase.runBare(TestCase.java:127)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:124)
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:118)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[junit] at junit.framework.TestSuite.run(TestSuite.java:203)
[junit] at junit.swingui.TestRunner$16.run(TestRunner.java:623)
[junit] Jun 20, 2004 10:22:19 PM net.sf.hibernate.connection.DriverManagerConnectionProvider close
[junit] INFO: cleaning up connection pool: jdbc:oracle:thin:@localhost:1521:test


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