title: Exception in thread "main" org.hibernate.service.spi.ServiceException: Unable to create requested service
body: <p>I am new in Hibernate and facing one problem with execution. I am following one tutorial and did almost everything same but still getting error:
  <strong>Exception in thread "main" org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]</strong> i have tried all suggestion from google and stackoverflow. Please suggest</p>
  
  <p>hibernate.cfg.xml</p>
  
  <pre><code>    &lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
      "//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  
  &lt;hibernate-configuration&gt;
  
    &lt;session-factory&gt;
      &lt;!-- Database connection settings --&gt;
      &lt;property name="connection.driver_class"&gt;org.postgresql.Driver&lt;/property&gt;
      &lt;property name="connection.url"&gt;jdbc:postgresql://localhost:5432/hibernatedb&lt;/property&gt;
      &lt;property name="connection.username"&gt;system&lt;/property&gt;
      &lt;property name="connection.password"&gt;*******&lt;/property&gt;
  
      &lt;!-- JDBC connection pool (use the built-in) --&gt;
      &lt;property name="connection.pool_size"&gt;1&lt;/property&gt;
  
      &lt;!-- SQL dialect --&gt;
      &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.PostgreSQLDialect&lt;/property&gt;
  
      &lt;!-- Enable Hibernate's automatic session context management 
      &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;--&gt;
  
      &lt;!-- Disable the second-level cache  --&gt;
       &lt;property name="cache.provider_class"&gt;org.hibernate.cache.internal.NoCacheProvider&lt;/property&gt;
  
      &lt;!-- Echo all executed SQL to stdout --&gt;
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
      &lt;!-- Drop and re-create the database schema on startup --&gt;
      &lt;property name="hbm2ddl.auto"&gt;create&lt;/property&gt;
      &lt;mapping class="com.firstHibernate.UserService"/&gt;
    &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>UserService.java </p>
  
  <pre><code>   package com.firstHibernate;
  
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.cfg.Configuration;
  
  public class UserService {
      public static void main(String[] args) {
          UserDetails userDetails = new UserDetails();
          userDetails.setUserId(12345);
          userDetails.setUserName("SRK");
  
          SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
          Session session = sessionFactory.openSession();
          session.beginTransaction();
          session.save(userDetails);
          session.getTransaction().commit();
          session.close();
      }
  
  }
  </code></pre>
  
  <p>UserDetails :</p>
  
  <pre><code>   package com.firstHibernate;
  
  import javax.persistence.Entity;
  import javax.persistence.Id;
  
  @Entity
  public class UserDetails {
      @Id
      private int userId;
      private String userName;
      public int getUserId() {
          return userId;
      }
      public void setUserId(int userId) {
          this.userId = userId;
      }
      public String getUserName() {
          return userName;
      }
      public void setUserName(String userName) {
          this.userName = userName;
      }
  
  
  }
  </code></pre>
  
  <p>Error </p>
  
  <pre><code>    Feb 21, 2016 6:37:40 PM org.hibernate.Version logVersion
  INFO: HHH000412: Hibernate Core {5.1.0.Final}
  Feb 21, 2016 6:37:40 PM org.hibernate.cfg.Environment &lt;clinit&gt;
  INFO: HHH000205: Loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.h2.Driver, hibernate.service.allow_crawling=false, hibernate.dialect=org.hibernate.dialect.H2Dialect, hibernate.max_fetch_depth=5, hibernate.format_sql=true, hibernate.generate_statistics=true, hibernate.connection.username=sa, hibernate.connection.url=jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1, hibernate.bytecode.use_reflection_optimizer=false, hibernate.connection.pool_size=5}
  Feb 21, 2016 6:37:40 PM org.hibernate.cfg.Environment buildBytecodeProvider
  INFO: HHH000021: Bytecode provider name : javassist
  Feb 21, 2016 6:37:41 PM org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver resolveEntity
  WARN: HHH90000012: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/hibernate-configuration. Use namespace http://www.hibernate.org/dtd/hibernate-configuration instead.  Support for obsolete DTD/XSD namespaces may be removed at any time.
  Feb 21, 2016 6:37:43 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager &lt;clinit&gt;
  INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
  Feb 21, 2016 6:37:43 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
  WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
  Feb 21, 2016 6:37:43 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  INFO: HHH10001005: using driver [org.postgresql.Driver] at URL [jdbc:postgresql://localhost:5432/hibernatedb]
  Feb 21, 2016 6:37:43 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  INFO: HHH10001001: Connection properties: {user=system, password=****}
  Feb 21, 2016 6:37:43 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  INFO: HHH10001003: Autocommit mode: false
  Feb 21, 2016 6:37:43 PM org.hibernate.engine.jdbc.connections.internal.PooledConnections &lt;init&gt;
  INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
  Exception in thread "main" org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:244)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
      at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)
      at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
      at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352)
      at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111)
      at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
      at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
      at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
      at com.firstHibernate.UserService.main(UserService.java:13)
  Caused by: org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
      at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator$1$1.convert(BasicConnectionCreator.java:105)
      at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.convertSqlException(BasicConnectionCreator.java:123)
      at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:41)
      at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:58)
      at org.hibernate.engine.jdbc.connections.internal.PooledConnections.addConnections(PooledConnections.java:106)
      at org.hibernate.engine.jdbc.connections.internal.PooledConnections.&lt;init&gt;(PooledConnections.java:40)
      at org.hibernate.engine.jdbc.connections.internal.PooledConnections.&lt;init&gt;(PooledConnections.java:19)
      at org.hibernate.engine.jdbc.connections.internal.PooledConnections$Builder.build(PooledConnections.java:138)
      at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:110)
      at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:74)
      at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
      at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145)
      at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66)
      at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
      at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
      ... 14 more
  Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "system"
      at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:427)
      at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:203)
      at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:65)
      at org.postgresql.jdbc.PgConnection.&lt;init&gt;(PgConnection.java:159)
      at org.postgresql.Driver.makeConnection(Driver.java:415)
      at org.postgresql.Driver.connect(Driver.java:283)
      at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:38)
      ... 29 more
  </code></pre>