1

I am getting error coming in to configure hibernate for postgresql database -

enter image description here

Error Log Details -

org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge]
    at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:402)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:270)
    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.console.ConsoleConfiguration$5.execute(ConsoleConfiguration.java:278)
    at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
    at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:107)
    at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:273)
    at org.hibernate.eclipse.console.workbench.LazySessionFactoryAdapter.getChildren(LazySessionFactoryAdapter.java:43)
    at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.getChildren(BasicWorkbenchAdapter.java:100)
    at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:106)
    at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:235)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:397)
    ... 13 more
Caused by: org.hibernate.cache.CacheException: could not instantiate CacheProvider [org.hibernate.cache.internal.NoCacheProvider]
    at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.<init>(RegionFactoryCacheProviderBridge.java:66)
    ... 18 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.cache.internal.NoCacheProvider cannot be found by org.hibernate.eclipse.libs_3.7.1.Final-v20131205-0918-B107
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:191)
    at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
    at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.<init>(RegionFactoryCacheProviderBridge.java:63)
    ... 18 more

UPDATE:

After the changes mentioned by @ConMan, I am getting a new error at the same place -

org.hibernate.HibernateException: Could not instantiate dialect class
    at org.hibernate.dialect.resolver.DialectFactory.constructDialect(DialectFactory.java:163)
    at org.hibernate.dialect.resolver.DialectFactory.buildDialect(DialectFactory.java:109)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:146)
    at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2155)
    at org.hibernate.console.ConsoleConfiguration$6.execute(ConsoleConfiguration.java:430)
    at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
    at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:107)
    at org.hibernate.console.ConsoleConfiguration.getSettings(ConsoleConfiguration.java:428)
    at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$2.execute(LazyDatabaseSchemaWorkbenchAdapter.java:119)
    at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
    at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:107)
    at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.readDatabaseSchema(LazyDatabaseSchemaWorkbenchAdapter.java:115)
    at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.getChildren(LazyDatabaseSchemaWorkbenchAdapter.java:65)
    at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:106)
    at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:235)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.lang.ClassCastException: org.hibernate.dialect.PostgreSQLDialect cannot be cast to org.hibernate.dialect.Dialect
    at org.hibernate.dialect.resolver.DialectFactory.constructDialect(DialectFactory.java:157)
    ... 16 more
3
  • Which Hibernate version are you using? Are you also using Spring? Commented Jan 17, 2015 at 13:47
  • I am using hibernate-core 4.3.0.Final as a maven dependency in project. My parent project is having Spring dependency as well. Commented Jan 17, 2015 at 14:00
  • Is this just error on IDEs hibernate view or does it come also when you run the code? Check the project classpath on IDE that its same as on Maven. Commented Jan 17, 2015 at 14:04

1 Answer 1

2

The problem is here:

Caused by: java.lang.ClassNotFoundException: org.hibernate.cache.internal.NoCacheProvider cannot be found by org.hibernate.eclipse.libs_3.7.1.Final-v20131205-0918-B107

This basically means that the implementation of hibernate you are using (org.hibernate.eclipse.libs...) does not contain the class NoCacheProvider.class.

An implementation of the NoCacheProvider can be found in the following dependencies:

  • hibernate-core - 3.6.0.Final, 3.5.0-Final, 3.3.0.SP1, 3.3.0.GA
  • com.springsource.org.hibernate - 3.3.2, 3.3.1, 3.2.6
  • hibernate-core - 3.6.10.Final-patched-play-1.2.5, 3.6.1.Final-patched-play-1.2, 3.5.6-Final-patched-play-1.1.1, 3.5.6-Final-patched-play-1.1
  • hibernate - 3.2.7.ga, 3.2.6.ga, 3.2.5.ga, 3.2.4.sp1, 3.2.4.ga, 3.2.3.ga, 3.2.2.ga, 3.2.1.ga, 3.2.0.ga, 3.2.0.cr3, 3.2.0.cr2, 3.2.0.cr1, 3.1.3, 3.1.2, 3.1.1, 3.1
  • hibernate - 3.1beta3, 3.1beta2, 3.1beta1, 3.0.5, 3.0.3
  • hibernate-all - beta3.SP15

Source: Grep Code

EDIT:

I have just seen that you are using hibernate-core 4.3.0.Final. It would appear that the NoCacheProvider class no longer exists in this version of hibernate. The recommended alternative is to use the following class instead:

org.hibernate.cache.internal.NoCachingRegionFactory
Sign up to request clarification or add additional context in comments.

5 Comments

I changed the way you mentioned but the error is different now and rest all is same. See update in my question. It seems as if properties like <property name="hibernate.default_schema">my_schema</property> aren't the good place for hibernate.cfg.xml and are the source of such problems.
what value are you using for the property hibernate.dialect, and what type of database are you using?
I am using <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property> and my database is PostgreSQL.
Are you using different versions of hibernate (i.e. between hibernate-core, hibernate-annotations, hibernate-search etc...), there could be a conflict between incompatible versions here?
I think you are pretty right. I just got this same feeling of version difference and so going with dependency hibernate-entitymanager that takes care of all. Let's see now what happens).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.