title: Hibernate + PostgreSQL throws an Exception: JDBC Driver class not found: org.postgresql.Drive
body: <p>I write a Java maven project for restful webservice using jersey + hibernate and having this errror:</p>
  
  <pre><code>javax.servlet.ServletException: org.hibernate.HibernateException: JDBC 
  Driver class not found: org.postgresql.Drive
  org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:419)
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:
  381)
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:
  344)
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:
  221)
  </code></pre>
  
  <p>Root cause:</p>
  
  <pre><code>org.hibernate.HibernateException: JDBC Driver class not found: 
  org.postgresql.Drive
  org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverMan
  agerConnectionProvider.java:89)
  org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(Con
  nectionProviderFactory.java:143)
  org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(Con
  nectionProviderFactory.java:84)
  org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.j
  ava:459)
  org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:90)
  org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:286
  3)
  org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859)
  org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)
  org.asad.login.login.loginservice.LoginService.getDatabaseUser(LoginService.
  java:25)
  org.asad.login.login.resources.LoginResource.get(LoginResource.java:21)
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  java.lang.reflect.Method.invoke(Unknown Source)
  org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFa
  ctory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
  org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatc
  her$1.run(AbstractJavaResourceMethodDispatcher.java:143)
  org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatc
  her.invoke(AbstractJavaResourceMethodDispatcher.java:160)
  org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvi
  der$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:203)
  org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatc
  her.dispatch(AbstractJavaResourceMethodDispatcher.java:97)
  org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMetho
  dInvoker.java:389)
  org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethod    Invoker.java:347)
  org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethod    Invoker.java:102)
  org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:303)
  org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
  org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
  org.glassfish.jersey.internal.Errors.process(Errors.java:315)
  org.glassfish.jersey.internal.Errors.process(Errors.java:297)
  org.glassfish.jersey.internal.Errors.process(Errors.java:267)
  org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.j    ava:317)
  org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:286)
  org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.jav
  a:1072)
  org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:399)
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:
  381)
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:
  344)
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:
  221)
  </code></pre>
  
  <p>The poml.xml file:</p>
  
  <pre><code>    &lt;project xmlns="http://maven.apache.org/POM/4.0.0" 
      enter code here
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0   
  
      http://maven.apache.org/maven-v4_0_0.xsd"&gt;
  
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;org.asad.login&lt;/groupId&gt;
  
      &lt;artifactId&gt;login&lt;/artifactId&gt;
  
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
      &lt;name&gt;login&lt;/name&gt;
  
      &lt;build&gt;
  
          &lt;finalName&gt;login&lt;/finalName&gt;
  
          &lt;plugins&gt;
  
              &lt;plugin&gt;
  
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
  
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
  
  
                  &lt;version&gt;2.5.1&lt;/version&gt;
  
                  &lt;inherited&gt;true&lt;/inherited&gt;
  
                  &lt;configuration&gt;
  
                      &lt;source&gt;1.7&lt;/source&gt;
  
                      &lt;target&gt;1.7&lt;/target&gt;
  
                  &lt;/configuration&gt;
  
              &lt;/plugin&gt;
  
  
          &lt;/plugins&gt;
  
      &lt;/build&gt;
  
      &lt;dependencyManagement&gt;
  
          &lt;dependencies&gt;
  
              &lt;dependency&gt;
  
                  &lt;groupId&gt;org.glassfish.jersey&lt;/groupId&gt;
  
                  &lt;artifactId&gt;jersey-bom&lt;/artifactId&gt;
  
                  &lt;version&gt;${jersey.version}&lt;/version&gt;
  
                  &lt;type&gt;pom&lt;/type&gt;
  
                  &lt;scope&gt;import&lt;/scope&gt;
  
              &lt;/dependency&gt;
  
          &lt;/dependencies&gt;
  
      &lt;/dependencyManagement&gt;
  
      &lt;dependencies&gt;
  
          &lt;dependency&gt;
  
              &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
  
              &lt;artifactId&gt;jersey-container-servlet-core&lt;/artifactId&gt;
  
              &lt;!-- use the following artifactId if you don't need servlet 2.x 
  
  compatibility --&gt;
  
              &lt;!-- artifactId&gt;jersey-container-servlet&lt;/artifactId --&gt;
  
          &lt;/dependency&gt;
  
  
       &lt;dependency&gt;
  
    &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
  
    &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
  
    &lt;version&gt;3.1.0&lt;/version&gt;
  
    &lt;scope&gt;provided&lt;/scope&gt;
  
          &lt;/dependency&gt;
  
      &lt;dependency&gt;
  
      &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
  
      &lt;artifactId&gt;hibernate-envers&lt;/artifactId&gt;
  
      &lt;version&gt;3.6.4.Final&lt;/version&gt;
  
      &lt;/dependency&gt;
  
  
      &lt;dependency&gt;
  
      &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
  
      &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
  
      &lt;version&gt;4.2.0.Final&lt;/version&gt;
  
  &lt;/dependency&gt;
  
  
  
      &lt;/dependencies&gt;
  
  
  
     &lt;properties&gt;
  
          &lt;jersey.version&gt;2.16&lt;/jersey.version&gt;
  
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
  
      &lt;/properties&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>The JDBC drivers are in classpath.</p>
  
  <p>hibernate.cfg.xml file:</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://www.hibernate.org/dtd/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.Drive&lt;/property&gt;
  
          &lt;property 
  
  name="connection.url"&gt;jdbc:postgresql://localhost:5432/logindb&lt;/property&gt;
  
          &lt;property name="connection.username"&gt;postgres&lt;/property&gt;
  
          &lt;property name="connection.password"&gt;project&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.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;update&lt;/property&gt;
  
  
          &lt;!-- Names the annotated entity class --&gt;
  
          &lt;mapping class="org.asad.dto.DatabaseClass"/&gt;
  
      &lt;/session-factory&gt;
  
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>Can anyone help?</p>