Hibernate 4 ConnectionProvider Class not found - java

I just updated Hibernate in my application to 4.3.4 (from 3.X), which caused some problems. The first was the new method of creating a sessionFactory, which I resolved.
The next problem, which I'm finding nothing about, is that I am now getting a ClassNotFoundException on org.hibernate.connection.ConnectionProvider
It should be noted that I'm using BoneCP (0.7.1) for my connection pool, which was working before the upgrade.
Any help would be appreciated. I'm pretty new to hibernate (I'm working on implementing it as a POC), and I may have left out some important details from my description here as such.
I don't need it to be the newest version, so I can revert back, but it would be nice to have the latest and greatest :)
Thanks!
Hibernate.cfg.xml snippet (with sensitive info replaced):
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">foo</property>
<property name="hibernate.connection.username">bob</property>
<property name="hibernate.default_schema">bar</property>
<property name="hibernate.dialect">package.path.MySQLCustomDialect</property>
<!-- Bonecp connection pool -->
<property name="hibernate.connection.provider_class">com.jolbox.bonecp.provider.BoneCPConnectionProvider</property>
<property name="bonecp.maxConnectionAgeInMinutes">5</property>
<property name="bonecp.idleConnectionTestPeriodInMinutes">0</property>
and so on ...
Stack Trace:
Exception in thread "Thread-110" java.lang.NoClassDefFoundError: org/hibernate/connection/ConnectionProvider
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2895)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:222)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:249)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:240)
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:125)
at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:194)
at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:120)
at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:55)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:83)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:223)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:197)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
at foo.utils.HibernateUtils.<clinit>(HibernateUtils.java:16)
at foo.objects.building.BuildingHelper.getBuildingByID(BuildingHelper.java:225)
at foo.objects.inventory.LocationInformation.<init>(LocationInformation.java:36)
at foo.objects.computermanagementframework.peripheral.PeripheralHelper.readLocation(PeripheralHelper.java:154)
at foo.objects.computermanagementframework.peripheral.PeripheralHelper.refresh(PeripheralHelper.java:556)
at foo.server.initialization.InitializeServerThread.run(InitializeServerThread.java:298)
at java.lang.Thread.run(Thread.java:695)
Caused by: java.lang.ClassNotFoundException: org.hibernate.connection.ConnectionProvider
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
... 36 more

Hibernate keeps changing the package containing the ConnectionProvider base class. It changed from version 3 to 4 and has changed again with verson 4.3.
As #teresa-carrigan mentions in a comment to this answer, you'll have to compile the latest BoneCPConnectionProvider.java (currently supporting Hibernate 4.3.1) and use that.
Or use Hibernate version 4.2.12.Final and see if that works with BoneCP 0.8 (as explained in the aforementioned answer).

Related

Unable to create JPA Connection Pooling in Karaf using C3P0

Unable to Create Hibernate-JPA Connection Pooling using C3P0. Facing the following error log:
com.employee.mgmt.sys.db.provider.EmployeeDBProvider(30)] The activate method has thrown an exception org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.connections.spi.ConnectionProvider]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:261)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:225)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:843)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:842)
at org.hibernate.osgi.OsgiPersistenceProvider.createContainerEntityManagerFactory(OsgiPersistenceProvider.java:112)
at org.apache.aries.jpa.container.impl.AriesEntityManagerFactoryBuilder.createEntityManagerFactory(AriesEntityManagerFactoryBuilder.java:55)
at com.employee.mgmt.sys.db.provider.EmployeeDBProvider.createEntityManagerFactoryObjects(EmployeeDBProvider.java:63)
at com.employee.mgmt.sys.db.provider.EmployeeDBProvider.activate(EmployeeDBProvider.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[:1.8.0_121] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_121]
at org.apache.felix.scr.impl.inject.BaseMethod.invokeMethod(BaseMethod.java:224)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.inject.BaseMethod.access$500(BaseMethod.java:39)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.inject.BaseMethod$Resolved.invoke(BaseMethod.java:617)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.inject.BaseMethod.invoke(BaseMethod.java:501)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:302)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:294)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:297)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:108)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:906)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:879)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:748)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:674)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:429)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:657)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:341)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:403)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.Activator.access$200(Activator.java:54)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:278)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259)[73:org.apache.felix.scr:2.0.6]
at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:232)[73:org.apache.felix.scr:2.0.6]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482)[org.osgi.core-6.0.0.jar:]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415)[org.osgi.core-6.0.0.jar:]
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232)[org.osgi.core-6.0.0.jar:]
at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444)[org.osgi.core-6.0.0.jar:]
at org.apache.felix.framework.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:915)[org.apache.felix.framework-5.6.1.jar:]
at org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:834)[org.apache.felix.framework-5.6.1.jar:]
at org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:516)[org.apache.felix.framework-5.6.1.jar:]
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4541)[org.apache.felix.framework-5.6.1.jar:]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2172)[org.apache.felix.framework-5.6.1.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)[org.apache.felix.framework-5.6.1.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984)[org.apache.felix.framework-5.6.1.jar:]
at org.apache.karaf.bundle.command.Install.execute(Install.java:96)[23:org.apache.karaf.bundle.core:4.0.8]
at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:83)[43:org.apache.karaf.shell.core:4.0.8]
at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:67)[43:org.apache.karaf.shell.core:4.0.8]
at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:87)[43:org.apache.karaf.shell.core:4.0.8]
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:480)[43:org.apache.karaf.shell.core:4.0.8]
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:406)[43:org.apache.karaf.shell.core:4.0.8]
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[43:org.apache.karaf.shell.core:4.0.8]
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:182)[43:org.apache.karaf.shell.core:4.0.8]
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:119)[43:org.apache.karaf.shell.core:4.0.8]
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:94)[43:org.apache.karaf.shell.core:4.0.8]
at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.java:274)[43:org.apache.karaf.shell.core:4.0.8]
at java.lang.Thread.run(Thread.java:745)
[:1.8.0_121] Caused by: org.hibernate.HibernateException: Could not instantiate connection provider [org.hibernate.c3p0.internal.C3P0ConnectionProvider]
at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:197)
at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:120)
at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:55)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:105)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:251) ... 64 more
Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.c3p0.internal.C3P0ConnectionProvider] as strategy [org.hibernate.engine.jdbc.connections.spi.ConnectionProvider]
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:128)
at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:194) ... 68 more
Requesting to please provide a solution how to create Connection Pooling using JPA in Karaf.
After carefully going through the error stacktrace that you've provided, I guess the problem is something to do with your hibernate.c3po.* properties that you've used.
You might want to refer to this documentation:
C3P0ConnectionProvider
A connection provider that uses a C3P0 connection pool. Hibernate will use this by default if the hibernate.c3p0.* properties are set
It's best to put these parameters all by yourself in c3p0 config file, and not using hibernate.c3p0.* properties.
A simple config file to help you fill in these details:
<?xml version="1.0" encoding="UTF-8"?>
<c3p0-config>
<default-config>
<property name="initialPoolSize">5</property>
<property name="minPoolSize">5</property>
<property name="maxPoolSize">10</property>
<property name="checkoutTimeout">3000</property>
<property name="maxStatementsPerConnection">30</property>
<property name="preferredTestQuery">SELECT 1 FROM DUAL</property>
<property name="testConnectionOnCheckin">true</property>
<property name="testConnectionOnCheckout">false</property>
<property name="idleConnectionTestPeriod">300</property>
</default-config>
</c3p0-config>
Hope that this helps!!!

Hive - Metastore Connection on Startup

I have started having failures on hive command as follows:
Logging initialized using configuration in file:/usr/local/someuser/hive/conf/hive-log4j.properties
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient
at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:346)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:625)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
Caused by: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient
at org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1412)
at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.<init>(RetryingMetaStoreClient.java:62)
at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.getProxy(RetryingMetaStoreClient.java:72)
at org.apache.hadoop.hive.ql.metadata.Hive.createMetaStoreClient(Hive.java:2453)
at org.apache.hadoop.hive.ql.metadata.Hive.getMSC(Hive.java:2465)
at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:340)
... 7 more
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.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1410)
... 12 more
Caused by: javax.jdo.JDOFatalUserException: There is no available StoreManager of type "rdbms". Make sure that you have put the relevant DataNucleus store plugin in your CLASSPATH and if defining a connection via JNDI or DataSource you also need to provide persistence property "datanucleus.storeManagerType"
NestedThrowables:
org.datanucleus.exceptions.NucleusUserException: There is no available StoreManager of type "rdbms". Make sure that you have put the relevant DataNucleus store plugin in your CLASSPATH and if defining a connection via JNDI or DataSource you also need to provide persistence property "datanucleus.storeManagerType"
at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:528)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.freezeConfiguration(JDOPersistenceManagerFactory.java:788)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.createPersistenceManagerFactory(JDOPersistenceManagerFactory.java:333)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.getPersistenceManagerFactory(JDOPersistenceManagerFactory.java:202)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at javax.jdo.JDOHelper$16.run(JDOHelper.java:1965)
at java.security.AccessController.doPrivileged(Native Method)
at javax.jdo.JDOHelper.invoke(JDOHelper.java:1960)
at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(JDOHelper.java:1166)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:808)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:701)
at org.apache.hadoop.hive.metastore.ObjectStore.getPMF(ObjectStore.java:310)
at org.apache.hadoop.hive.metastore.ObjectStore.getPersistenceManager(ObjectStore.java:339)
at org.apache.hadoop.hive.metastore.ObjectStore.initialize(ObjectStore.java:248)
at org.apache.hadoop.hive.metastore.ObjectStore.setConf(ObjectStore.java:223)
at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:62)
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:117)
at org.apache.hadoop.hive.metastore.RawStoreProxy.<init>(RawStoreProxy.java:58)
at org.apache.hadoop.hive.metastore.RawStoreProxy.getProxy(RawStoreProxy.java:67)
at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.newRawStore(HiveMetaStore.java:497)
at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.getMS(HiveMetaStore.java:475)
at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.createDefaultDB(HiveMetaStore.java:523)
at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.init(HiveMetaStore.java:397)
at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.<init>(HiveMetaStore.java:356)
at org.apache.hadoop.hive.metastore.RetryingHMSHandler.<init>(RetryingHMSHandler.java:54)
at org.apache.hadoop.hive.metastore.RetryingHMSHandler.getProxy(RetryingHMSHandler.java:59)
at org.apache.hadoop.hive.metastore.HiveMetaStore.newHMSHandler(HiveMetaStore.java:4944)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.<init>(HiveMetaStoreClient.java:171)
... 17 more
Caused by: org.datanucleus.exceptions.NucleusUserException: There is no available StoreManager of type "rdbms". Make sure that you have put the relevant DataNucleus store plugin in your CLASSPATH and if defining a connection via JNDI or DataSource you also need to provide persistence property "datanucleus.storeManagerType"
at org.datanucleus.NucleusContext.createStoreManagerForProperties(NucleusContext.java:1217)
at org.datanucleus.NucleusContext.initialise(NucleusContext.java:356)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.freezeConfiguration(JDOPersistenceManagerFactory.java:775)
... 46 more
Here is the hive-site
<configuration>
<property>
<name>mapred.reduce.tasks</name>
<value>6</value>
<name>mapred.map.tasks</name>
<value>7</value>
</property>
<property>
<name>hive.exec.scratchdir</name>
<value>/data/cloud/hive/logs/hive-${user.name}</value>
</property>
<property>
<name>hive.exec.local.scratchdir</name>
<value>/data/cloud/hive/logs/hive-${user.name}</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://somehost:3306/hive?createDatabaseIfNotExist=true</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>xx</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>xx</value>
<description>password to use against metastore database</description>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
</configuration>
the version is 0.13.1
I have checked the lib directories of hadoop and hive both, as the logs complains about the classpath, but the jar datanucleus-rdbms-3.2.9.jar is already in the folder. I have tried to restart the metastore service as well but it didnt help at all.
any other point which might cause the error above? i was curious if there were any config changes prior to the errors, but it seems like no config updates either...
EDIT
Verbose logs: http://pastebin.com/jggaXF1X
After digging the logs, as we were discussing with #NeilStockton in the comments, i have tried to redownload the related jar file, in the folder where the jar itself already exists... and it worked after the redownload...

Postgres JDBC Issue - No suitable driver found for postgresql://localhost:5432/postgres - JDBC driver already configured on buildpath

I am aware this issue comes up when no proper jdbc driver jar is configured in the build path, I have tried adding a few jdbc jars for postgres, yet I face the issue. Please find the below jars I tried.
Using
postgres : 1.16.1
Eclipse Version: Indigo Service Release 2
Java version : 8
Jars I tried
postgresql-9.4.1208.jre6
postgresql-connector-jdbc4.jar
postgresql-jdbc.jar
postgresql-9.3-1103.jdbc3
postgresql-9.2-1003-jdbc4-sources.jar
pg73jdbc3
jdbc7.1-1.1
Reading other posts on stack overflow, I even tried setting the system environmental variables as below..
User Variables - Admin - classpath
C:\Program Files\PostgreSQL\9.2\lib
System Variable - path
C:\Program Files\PostgreSQL\9.2\bin
Not sure if this is required
Database details setup in my .properties file
jdbc.driverClassName=org.postgresql.Driver
jdbc.url=postgresql://localhost:5432/postgres
jdbc.username=admin
jdbc.password=admin
Using spring framework based application
Logs :
org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: No suitable driver found for postgresql://localhost:5432/postgres
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:240)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy8.getCollegeDetails(Unknown Source)
at com.cts.bo.HESBO.registerCourse(HESBO.java:42)
at com.cts.facade.HESFacade.registerCourse(HESFacade.java:34)
at com.cts.manager.HESManager.registerCourse(HESManager.java:34)
at com.cts.presentation.Tester.registerCourse(Tester.java:66)
at com.cts.presentation.Tester.main(Tester.java:159)
Caused by: java.sql.SQLException: No suitable driver found for postgresql://localhost:5432/postgres
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:173)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:164)
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:149)
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:119)
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:202)
... 11 more
Please guide as for what needs to be done.Thanks
You don't add url while filling the database details for postgresql. You instead do the following.
<bean id="dataSource" class="org.postgresql.xa.PGXADataSource">
<property name="user" value="${username}" />
<property name="password" value="${password}" />
<property name="portNumber" value ="${portNumber}" />
<property name="databaseName" value="${databaseName}" />
<property name="serverName" value="${serverName}" />
</bean>
in your application context and
username=yourusername
password=******
portNumber=5432
databaseName=yourdb
serverName=localhost
in your property file.Later ofcourse you need to utilize the datasource bean. Look at the following, https://jdbc.postgresql.org/documentation/publicapi/org/postgresql/xa/PGXADataSource.html.

Can't bind Hibernate session factory into java:app in WildFly 8.2.1

I am attempting to register a Hibernate Session Factory from a persistence unit in a applications deployed to WildFly 8.2.1 and I am encountering a warning exception from the Hibernate 4 code (listed below). And when I look at JNDI in the WildFly console, the session factories are definitely not registered. I would like them to be in the "java:app" scope so that I can avoid naming collisions when more that one application might have the same session factory name.
Registering an entity manager to this scope works fine.
If I leave the "java:app" prefix off the session factory name it bind just fine into JNDI, but at a global scope. I understand that I can impose some sort of name-spacing, but I was hoping I would not have to.
Any input would be appreciated. Thank you.
Details below...
The persistence unit
<persistence-unit name="myPU" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:/jdbc/MyDS</jta-data-source>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<mapping-file>MySchema.hbm.xml</mapping-file>
<properties>
<property name="jboss.entity.manager.jndi.name" value="java:app/em/MY_EM" />
<property name="hibernate.session_factory_name" value="java:app/sessions/my_FACTORY"/>
<property name="hibernate.query.imports" value="com.my.model" />
<property name="hibernate.current_session_context_class" value="thread" />
<property name="hibernate.use_outer_join" value="true" />
<property name="hibernate.jdbc.use_streams_for_binary" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" />
</properties>
</persistence-unit>
Exception snippet
16:14:50,044 WARN [org.hibernate.internal.SessionFactoryRegistry] (ServerService Thread Pool -- 64) - HHH000277: Could not bind factory to JNDI: org.hibernate.engine.jndi.JndiException: Error creating intermediate context [java:app]
Caused by: javax.naming.NameNotFoundException: java:app
Full Warning exception from Hibernate
16:14:50,044 WARN [org.hibernate.internal.SessionFactoryRegistry] (ServerService Thread Pool -- 64) - HHH000277: Could not bind factory to JNDI: org.hibernate.engine.jndi.JndiException: Error creating intermediate context [java:app]
at org.hibernate.engine.jndi.internal.JndiServiceImpl.bind(JndiServiceImpl.java:205) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.engine.jndi.internal.JndiServiceImpl.bind(JndiServiceImpl.java:159) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.internal.SessionFactoryRegistry.addSessionFactory(SessionFactoryRegistry.java:103) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:497) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:852) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
at org.jboss.as.jpa.hibernate4.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44) [jipijapa-hibernate4-3-1.0.1.Final.jar:]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:154) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.8.0_51]
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:474) [wildfly-security-manager-1.0.0.Final.jar:1.0.0.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_51]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_51]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: javax.naming.NameNotFoundException: java:app
at org.jboss.as.naming.InitialContext$DefaultInitialContext.findContext(InitialContext.java:187) [wildfly-naming-8.2.1.Final.jar:8.2.1.Final]
at org.jboss.as.naming.InitialContext$DefaultInitialContext.createSubcontext(InitialContext.java:294) [wildfly-naming-8.2.1.Final.jar:8.2.1.Final]
at org.jboss.as.naming.NamingContext.createSubcontext(NamingContext.java:398) [wildfly-naming-8.2.1.Final.jar:8.2.1.Final]
at javax.naming.InitialContext.createSubcontext(InitialContext.java:489) [rt.jar:1.8.0_51]
at javax.naming.InitialContext.createSubcontext(InitialContext.java:489) [rt.jar:1.8.0_51]
at org.hibernate.engine.jndi.internal.JndiServiceImpl.bind(JndiServiceImpl.java:202) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
... 18 more
I may have found the answer...
Although it is not exactly the answer I wanted. But, it makes sense. The reason that Hibernate's JNDI binding robots cannot find the java:app subcontext is because, I think, it is attempting to find that name at the root and it does not exist there. JBoss/WildFly on the other have seems to have some implicit context when deploying the application and actually as the java:app existing under the applications/<module-name> inside the JNDI tree. Hibernate doesn't know anything about this structure.
I've modified my implementation is organize these session factory bindings by application name at the root of the JNDI tree like this:
hib > myApp > sessions > MY_SESSION_FACTORY
I hope this helps someone else out.

could not instantiate RegionFactory

I am trying to enable secondary cache, but i am getting exception.
Code for secondary cache in persistence.xml is given below:
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.EhCache"/>
</properties>
Stacktrace for exception is:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.org.JPAUtil.<clinit>(JPAUtil.java:21)
at com.org.Main.main(Main.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
at java.lang.Class.getConstructor0(Class.java:2714)
at java.lang.Class.getConstructor(Class.java:1674)
at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:409)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:280)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2833)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2829)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
at com.org.JPAUtil.<clinit>(JPAUtil.java:17)
... 6 more
Caused by: java.lang.ClassNotFoundException: net.sf.ehcache.CacheException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 20 more
After adding jar for ehcache, I'm getting exception as
Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.EhCache]
at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:423)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:280)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2833)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2829)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902)
... 10 more
Caused by: java.lang.InstantiationException: org.hibernate.cache.EhCache
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:325)
at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:419)
... 15 more
Instead of:
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.EhCache"/>
Use:
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider"/>
For example, using Hibernate 4.x along with the JAR files hibernate-ehcache-4.3.10.Final.jar and slf4j-api-1.6.1.jar, modify persistence.xml:
<properties>
<!-- ... other properties ... -->
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="false"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider"/>
</properties>
Then ensure that hibernate-ehcache-4.3.10.Final.jar and slf4j-api-1.6.1.jar are deployed to JBoss.
Do not include ehcache-core-2.4.3.jar.
Now you can annotate entities, such as:
#Entity
#Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL, region = "region_name")
public class MyEntity implements Serializable {
// ...
}
Make sure that Hibernate and ehcache are in the same directory. Either application server lib or your application WEB-INF/lib
Check whether the ehcache-x.x.jar is in your classpath. In eclipse, you can check it by right click your project -> build path -> configure build path. If you missed that jar, you can download it from here. If you are using maven, you can just put the following dependency in your pom.xml:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.6.0</version>
</dependency>
Use the below property in your persistence.xml.
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
It will resolve the issue.

Categories