title: Exception in thread "main" java.util.ServiceConfigurationError
body: <p>This error is occuring with Hibernate 3.2 and resolved by using <code>ServiceRegistryBuilder</code>
  This is my code:</p>
  
  <pre><code>public class HibernateTest {
      public static void main(String[] args) {
      UserDetails user = new UserDetails();
      user.setUserId(1);
      user.setUserName("Sam");
      SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
      Session session = sessionFactory.openSession();
      session.beginTransaction();
      session.save(user);
      session.getTransaction().commit();
            }
       } 
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Exception in thread "main" java.util.ServiceConfigurationError: org.hibernate.boot.registry.selector.StrategyRegistrationProvider: Provider org.hibernate.cache.infinispan.StrategyRegistrationProviderImpl not found
      at java.util.ServiceLoader.fail(ServiceLoader.java:231)
      at java.util.ServiceLoader.access$300(ServiceLoader.java:181)
      at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:365)
      at java.util.ServiceLoader$1.next(ServiceLoader.java:445)
      at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.loadJavaServices(ClassLoaderServiceImpl.java:340)
      at org.hibernate.boot.registry.selector.internal.StrategySelectorBuilder.buildSelector(StrategySelectorBuilder.java:162)
      at org.hibernate.boot.registry.BootstrapServiceRegistryBuilder.build(BootstrapServiceRegistryBuilder.java:222)
      at org.hibernate.cfg.Configuration.&lt;init&gt;(Configuration.java:119)
  </code></pre>
  
  <p>This was the error while executing the hibernate framework with wrong api's.
  This problem was resolved by changing my code like this:</p>
  
  <pre><code>import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.cfg.Configuration;
  import org.hibernate.service.ServiceRegistry;
  import org.hibernate.service.ServiceRegistryBuilder;
  public class HibernateTest {
  private static SessionFactory sessionFactory;
  public static void main(String[] args) {
      UserDetails user = new UserDetails();
      user.setUserId(1);
      user.setUserName("Sam");
       if (sessionFactory == null) {
              Configuration configuration = new Configuration().configure();
              ServiceRegistryBuilder registry = new ServiceRegistryBuilder();
              registry.applySettings(configuration.getProperties());
              ServiceRegistry serviceRegistry = registry.buildServiceRegistry();  
              sessionFactory = configuration.buildSessionFactory(serviceRegistry);           
          }
  
      Session session = sessionFactory.openSession();
      session.beginTransaction();
      session.save(user);
      session.getTransaction().commit();
  }
  }
  </code></pre>
  
  <p>This was the code.</p>