Error in Hibernate Tool in Eclipse Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]
30,643
Solution 1
add mysql driver jar in classpath.
mysql-connector-java-5.1.21-bin.jar
Solution 2
I write here as in comments is difficult to be clear. In the class
org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator
put a breakpoint in the method below, in the return statement. It causes the exception thrown in your runtime. In debug mode we will understand what is happening and ,hopefully, complete this reply:
private ConnectionProvider More ...instantiateExplicitConnectionProvider(
String providerClassName,
ClassLoaderService classLoaderService) {
try {
LOG.instantiatingExplicitConnectionProvider( providerClassName );
return (ConnectionProvider) classLoaderService.classForName( providerClassName ).newInstance();
}
catch ( Exception e ) {
throw new HibernateException( "Could not instantiate connection provider [" + providerClassName + "]", e );
}
}
Author by
Admin
Updated on July 09, 2022Comments
-
Admin almost 2 years
hibernate.cfg.xml
<hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property> <property name="hibernate.connection.password">cisadm</property> <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:CCB240</property> <property name="hibernate.connection.username">cisadm</property> <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property> </session-factory> </hibernate-configuration>
hibernate.properties
hibernate.connection.driver_class = oracle.jdbc.driver.OracleDriver hibernate.connection.url = jdbc:oracle:thin:@localhost:1521:CCB240 hibernate.connection.username = cisadm hibernate.connection.password = ENC(YoYU3xkTjrrX1hIbldx9DhkGadCBjvliVNh/i4CWQvg=) hibernate.dialect = org.hibernate.dialect.Oracle10gDialect hibernate.show_sql = false hibernate.max_fetch_depth = 2 hibernate.transaction.factory_class = org.hibernate.transaction.JDBCTransactionFactory hibernate.jdbc.fetch_size = 100 hibernate.jdbc.batch_size = 30 hibernate.query.factory_class=org.hibernate.hql.classic.ClassicQueryTranslatorFactory hibernate.cache.use_second_level_cache = false hibernate.query.substitutions = true 'Y', false 'N' hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider hibernate.c3p0.acquire_increment=1 hibernate.c3p0.idle_test_period=180 hibernate.c3p0.max_size=60 hibernate.c3p0.max_statements=0 hibernate.c3p0.min_size=10
And my Hibernate Tool Configuration are in the link below.
But when I run the hql in HQL Editor I get the below error
org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider] at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:193) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:156) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:139) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:208) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:85) at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:165) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:139) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71) at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2259) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2255) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1724) at org.jboss.tools.hibernate4_0.HibernateExtension4_0$3.execute(HibernateExtension4_0.java:118) at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63) at org.jboss.tools.hibernate4_0.HibernateExtension4_0.execute(HibernateExtension4_0.java:211) at org.jboss.tools.hibernate4_0.HibernateExtension4_0.buildSessionFactory(HibernateExtension4_0.java:110) at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:283) at org.hibernate.eclipse.console.actions.ExecuteQueryAction.execute(ExecuteQueryAction.java:82) at org.hibernate.eclipse.console.actions.ExecuteQueryAction.run(ExecuteQueryAction.java:56) at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) at org.hibernate.eclipse.console.actions.ExecuteQueryAction.runWithEvent(ExecuteQueryAction.java:60) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:452) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) 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: Could not instantiate connection provider [org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider] at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:190) at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:112) at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:54) at org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:69) at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:183) ... 48 more
I am adding the hibernate-c3p0-4.1.0.Final.jar and in the drop down I am selecting Hibernate version as 4. What am I doing wrong?
I am using:
- JBoss Hibernate Tool 3.3
- Eclipse Indigo
-
Admin over 10 yearsHi Thanks for your inputs. Actually whats happening is my java project has hibernate version 4.1 and my hibernate tools plugin is using hibernate 3.5.1 when I use c3p0 hibernate-c3p0-3.5.1-Final.jar as its for hibernate 3.5 and changed the hibernate tools configuration Main tab to hibernate version to 3.5 its working fine. But I want to use hibernate version 4.1.0 and c3p0 hibernate-c3p0-4.1.0.Final.jar. Plz suggest me what configuration should I doi to use Hibernate 4.1 in eclipse Indigo
-
blackbird014 over 10 yearsYou configure the tools to use hibernate 4.1, you use c3p0 4.1 and should work. If not it means that your application server is loading still hibernate 3.5.1. Therefore zou will need to change the application server classpath.
-
Admin over 10 yearsMy application server and web dynamic project in eclipse project already has 4.1 in class path but the prob arises in my hibernate tools i.e jboss tools(hibernate console) in this i am getting this error
-
blackbird014 over 10 yearslet me understand.1) project hib 3.5.1, tools plugin hib 3.5.1, c3p0-3.5.1 => OK. 2) project hib 4.1, tools plugin hib 4.1, c3p0-4.1 => False! If 2) is like that I am quite sure that you think to have the 2) setup but in runtime the versions are not matching. Putting the debug where I said you can verify 100% what is happening. Check this and then I have a better picture.
-
Admin over 10 yearsIn 1)project hib 4.1.0, jboss tools plugin hib 3.5.1, c3p0-3.5.1 => ok 2)project hib 4.1.0, jboss tools plugin hib 4.1.0, c3p0-4.1.0 => error So in both the cases I am having proj hib set to 4.1.0. and in the proj is .jar for all pojo which I have included in the class path and I am just trying to run the HQL Editor so thts the reason I am not able to figure where to put the above logic u have provided
-
blackbird014 over 10 yearsputting the breakpoint in the bad case what do you see? In the stack. Without that we cannot decide anything.
-
Admin over 10 yearsthere is no class which is invoking the HQL editor the error is above which only coming in the case if i run a hql in hql editor in the case 2). So i m unable to put breakpoint. only error i get is above
-
blackbird014 over 10 yearsgot it. did you installed the eclipse plugin from here? jboss.org/tools/download If it is not working with your conf you have found a bug that need to be reported. but u can workaround it.... Check the link, be sure to install the last and retry your stuff. If it is not working for me it is a bug not your fault.
-
Admin over 10 yearsS I have downloaded from this site only. But the latest version of jboss tools is for eclipse Kepler but I am using eclipse Indigo and even in latest jboss tool the hibernate version is not 4.1 but jboss version is 4.1 which is mentioned in the features file.The latest jboss version 4.1 has hibernate version 3.7 but not hib 4.1. So plz let me know if any work around exists
-
blackbird014 over 10 yearsI don't have eclipse installed here now. if you are crazy enough: start eclipse passing -cp <the jar 4.1final> and see what happens. I will check at home in case the problem is still open.
-
Admin over 10 yearsAny luck did u try that?
-
blackbird014 over 10 yearsworking till midnight, I couldn't.... try this in the meanwhile wiki.eclipse.org/…
-
Sameer Mirji about 8 yearsWhen you answer a question, you may also want to describe what changes you have done briefly.