title: Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/hibernate/service/jdbc/connections/spi/ConnectionProvider
body: <p>Getting the following error while trying to update the hibernate version 3.6.. to 4.3.*</p>
  
  <pre><code>Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/hibernate/service/jdbc/connections/spi/ConnectionProvider
  java.lang.NoClassDefFoundError: org/hibernate/service/jdbc/connections/spi/ConnectionProvider
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
      at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
      at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:415)
      at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:377)
      at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:224)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:348)
      at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:242)
      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:105)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:251)
      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:1887)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
  </code></pre>
  
  <p>My Hibernate Util class is </p>
  
  <pre><code>private static SessionFactory buildSessionFactory() {
          try {
              SessionFactory sf = null;
              Configuration configuration = new Configuration().configure();
              //From the properties file
              serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
                      configuration.getProperties()).build();
              if (StringUtils.isNotBlank(Config.getHibernateConfigFile())) {
                  ClassLoader loader = HibernateUtil.class.getClassLoader();
                  if (loader == null)
                      loader = ClassLoader.getSystemClassLoader();
  
                  java.net.URL configURL = loader.getResource(Config.getHibernateConfigFile());
                  if (null != configURL) {
                      log.info("Configuring hibernate using " + Config.getHibernateConfigFile() + " located at " + configURL.toString());
  //                 sf = new Configuration().configure(configURL).buildSessionFactory();
                      configuration = configuration.configure(configURL);
                      serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
                      sf = configuration.buildSessionFactory(serviceRegistry);
  
                  } else
                      log.warn("Config file not found " + Config.getHibernateConfigFile());
              }
              //Default hibernate.cfg.xml from resource
              if (null == sf) {
                  sf = configuration.buildSessionFactory(serviceRegistry);
              }
              return sf;
          } catch (Throwable ex) {
              // Make sure you log the exception, as it might be swallowed
              System.err.println("Initial SessionFactory creation failed." + ex);
              ex.printStackTrace();
              throw new ExceptionInInitializerError(ex);
          }
      }
  </code></pre>
  
  <p>I tried lot of ways to resolve it unable to find it, Can someone help me on the same :)</p>
  
  <p>my hibernate.cfg.xml </p>
  
  <pre><code> &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
          &lt;property name="connection.url"&gt;jdbc:mysql://localhost:3306/dummyDb?useLegacyDatetimeCode=false&lt;/property&gt;
          &lt;property name="connection.username"&gt;bobby&lt;/property&gt;
          &lt;property name="connection.password"&gt;&lt;/property&gt;
  
  
          &lt;!-- BonceCP connection pool --&gt;
          &lt;property name="hibernate.connection.provider_class"&gt;com.jolbox.bonecp.provider.BoneCPConnectionProvider
          &lt;/property&gt;
          &lt;property name="bonecp.setIdleMaxAgeInMinutes"&gt;60&lt;/property&gt;
          &lt;property name="bonecp.setIdleConnectionTestPeriodInMinutes"&gt;5&lt;/property&gt;
          &lt;property name="bonecp.partitionCount"&gt;3&lt;/property&gt;
          &lt;property name="bonecp.acquireIncrement"&gt;2&lt;/property&gt;
          &lt;property name="bonecp.maxConnectionsPerPartition"&gt;5&lt;/property&gt;
          &lt;property name="bonecp.minConnectionsPerPartition"&gt;2&lt;/property&gt;
          &lt;property name="bonecp.statementsCacheSize"&gt;50&lt;/property&gt;
          &lt;property name="bonecp.releaseHelperThreads"&gt;3&lt;/property&gt;
          &lt;property name="connection.autoReconnect"&gt;true&lt;/property&gt;
          &lt;property name="connection.autoReconnectForPools"&gt;true&lt;/property&gt;
          &lt;!--&lt;property name="bonecp.idleConnectionTestPeriodInMinutes"&gt;60&lt;/property&gt;--&gt;
          &lt;!-- SQL dialect --&gt;
          &lt;property name="dialect"&gt;org.hibernate.dialect.MySQL5InnoDBDialect&lt;/property&gt;
          &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5InnoDBDialect&lt;/property&gt;
  </code></pre>
  
  <p>My pom.xml is</p>
  
  <pre><code>&lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
              &lt;version&gt;4.3.9.Final&lt;/version&gt;
          &lt;/dependency&gt;
   &lt;dependency&gt;
              &lt;groupId&gt;com.jolbox&lt;/groupId&gt;
              &lt;artifactId&gt;bonecp&lt;/artifactId&gt;
              &lt;version&gt;0.8.0.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.jolbox&lt;/groupId&gt;
              &lt;artifactId&gt;bonecp-provider&lt;/artifactId&gt;
              &lt;version&gt;0.8.0-alpha1&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>