title: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] Unable to load class [org.postgresql.Driver]
body: <p>i am using eclipse mars
  with hibernate-release-5.0.7.Final
  with postgreSQL </p>
  
  <p>i m getting that error mentioned in error 
  i m attaching code with it plzz help me i am new with hibernate.</p>
  
  <p>index.jsp:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;HIbernet Demo&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form action="login" method="post"&gt;
  ID: &lt;input type="text" name="txt1"&gt;&lt;br&gt;
  Name: &lt;input type="text" name="txt2"&gt;&lt;br&gt;
  &lt;input type="submit"&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>hibernate.cfg.xml:</p>
  
  <pre><code>&lt;!--
    ~ Hibernate, Relational Persistence for Idiomatic Java
    ~
    ~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
    ~ See the lgpl.txt file in the root directory or &lt;http://www.gnu.org/licenses/lgpl-2.1.html&gt;.
  
  --&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/abc&lt;/property&gt;
  &lt;property name="connection.username"&gt;postgres&lt;/property&gt;
  &lt;property name="connection.password"&gt;admin&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="dialect"&gt;org.hibernate.dialect.PostgreSQLDialect&lt;/property&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;!-- Names the annotated entity class --&gt;
  &lt;mapping class="org.myapp.clg.dto.Vai"/&gt;
  
  &lt;/session-factory&gt;&lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>login.java</p>
  
  <pre><code>package org.myapp.clg;
  
  import java.io.IOException;
  import java.io.PrintWriter;
  
  import javax.servlet.ServletException;
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.cfg.Configuration;
  import org.myapp.clg.dto.Vai;
  
  @WebServlet(description = "login controller", urlPatterns = { "/login" })
  public class login extends HttpServlet {
      private static final long serialVersionUID = 1L;
  
      public login() {
          super();
      }
  
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
          PrintWriter pw = response.getWriter();
          SessionFactory sf = new Configuration().configure().buildSessionFactory();
          Session s1 = sf.openSession();
          pw.println("id:"+ request.getParameter("txt1")+"/nname:"+ request.getParameter("txt2"));
  
          try
          {
          Vai v1 = new Vai();
          v1.setUid(1);
          v1.setName("vaibhav");      
          s1.beginTransaction();
          s1.save(v1);
          s1.getTransaction().commit();
          s1.close();
          }
          catch(Exception ex)
          {
              pw.println(ex);
              s1.getTransaction().rollback();
              s1.close();
          }
      }
  }
  </code></pre>
  
  <p>4 vai.java</p>
  
  <pre><code>package org.myapp.clg.dto;
  
  import javax.persistence.Entity;
  import javax.persistence.Id;
  
  @Entity 
  public class Vai {
  
      @Id
      private int Uid;
      private String name;
      public int getUid() {
          return Uid;
      }
      public void setUid(int uid) {
          Uid = uid;
      }
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
  
  }
  </code></pre>
  
  <p>i am using servlet and JSP for this n on console i m getting this error discription: </p>
  
  <pre><code>Feb 11, 2016 1:34:51 PM org.hibernate.Version logVersion
  INFO: HHH000412: Hibernate Core {5.0.7.Final}
  Feb 11, 2016 1:34:51 PM org.hibernate.cfg.Environment &lt;clinit&gt;
  INFO: HHH000206: hibernate.properties not found
  Feb 11, 2016 1:34:51 PM org.hibernate.cfg.Environment buildBytecodeProvider
  INFO: HHH000021: Bytecode provider name : javassist
  Feb 11, 2016 1:34:51 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager &lt;clinit&gt;
  INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
  Feb 11, 2016 1:34:51 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
  WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
  Feb 11, 2016 1:34:51 PM org.apache.catalina.core.StandardWrapperValve invoke
  SEVERE: Servlet.service() for servlet [org.myapp.clg.login] in context with path [/myapp] threw exception
  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 org.myapp.clg.login.doPost(login.java:28)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Unknown Source)
  Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [org.postgresql.Driver]
      at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:229)
      at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.loadDriverIfPossible(DriverManagerConnectionProviderImpl.java:161)
      at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildCreator(DriverManagerConnectionProviderImpl.java:117)
      at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:73)
      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)
      ... 36 more
  Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.postgresql.Driver
      at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:217)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Unknown Source)
      at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:226)
      ... 47 more
  </code></pre>
  
  <p>m stuck on it :( plz help me </p>
  
  <p>this is image :</p>
  
  <p><a href="https://i.stack.imgur.com/bGHu1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bGHu1.png" alt="enter image description here"></a></p>