title: Hibernate: could not load requested class
body: <p>I am using Hibernate with mysql but on runtime I get the following exception:</p>
  
  <pre><code>Exception in thread "main" org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver org.h2.Driver class not found
      at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:107)
      at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
      at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)
      at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)
      at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
      at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:77)
      at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2283)
      at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2279)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1748)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1788)
      at driver.Main.main(Main.java:29)
  Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.h2.Driver]
      at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141)
      at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:104)
      ... 14 more
  Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.h2.Driver
      at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$1.findClass(ClassLoaderServiceImpl.java:99)
      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.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138)
      ... 15 more
  </code></pre>
  
  <p>hibernate.cfg.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration SYSTEM 
  "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  
  &lt;hibernate-configuration&gt;
     &lt;session-factory&gt;
     &lt;property name="hibernate.dialect"&gt;
        org.hibernate.dialect.MySQLDialect
     &lt;/property&gt;
     &lt;property name="hibernate.connection.driver_class"&gt;
        com.mysql.jdbc.Driver
     &lt;/property&gt;
  
     &lt;property name="hibernate.connection.url"&gt;
        jdbc:mysql://localhost/ict
     &lt;/property&gt;
     &lt;property name="hibernate.connection.username"&gt;
        root
     &lt;/property&gt;
     &lt;property name="hibernate.connection.password"&gt;
        root
     &lt;/property&gt;
  
  &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>I am using annotated classes like</p>
  
  <pre><code>@Entity
  @Table (name="method_msisdn_info")
  public class MSISDN {
  
      public MSISDN(){}
  
      @Id @GeneratedValue @Column(name="msisdn_id")
      int msisdn_id;
      public int getMsisdn_id() {
          return msisdn_id;
      }
      public void setMsisdn_id(int msisdn_id) {
          this.msisdn_id = msisdn_id;
      }
  
      @Column(name="destination_msisdn")
      BigInteger destination_msisdn;
      public BigInteger getDestination_msisdn() {
          return destination_msisdn;
      }
      public void setDestination_msisdn(BigInteger destination_msisdn) {
          this.destination_msisdn = destination_msisdn;
      }
  
      @Column(name="product_list")
      String product_list;
      public String getProduct_list() {
          return product_list;
      }
      public void setProduct_list(String product_list) {
          this.product_list = product_list;
      }
  
      @Column(name="country")
      String country;
      public String getCountry() {
          return country;
      }
      public void setCountry(String country) {
          this.country = country;
      }
  
      @Column(name="operator")
      String operator;
      public String getOperator() {
          return operator;
      }
      public void setOperator(String operator) {
          this.operator = operator;
      }
  
      @Column(name="destination_currency")
      String destination_currency;
      public String getDestination_currency() {
          return destination_currency;
      }
      public void setDestination_currency(String destination_currency) {
          this.destination_currency = destination_currency;
      }
  
      @Column(name="error_code")
      int error_code;
      public int getError_code() {
          return error_code;
      }
      public void setError_code(int error_code) {
          this.error_code = error_code;
      }
  
      @Column(name="wholesale_price_list")
      String wholesale_price_list;
      public String getWholesale_price_list() {
          return wholesale_price_list;
      }
      public void setWholesale_price_list(String wholesale_price_list) {
          this.wholesale_price_list = wholesale_price_list;
      }
  
      @Column (name ="retails_price_list")
      String retail_price_list;
      public String getRetail_price_list() {
          return retail_price_list;
      }
      public void setRetail_price_list(String retail_price_list) {
          this.retail_price_list = retail_price_list;
      }
  
      @Column(name="marked_processed")
      int marked_processed;
      public int getMarked_processed() {
          return marked_processed;
      }
      public void setMarked_processed(int marked_processed) {
          this.marked_processed = marked_processed;
      }
  }
  </code></pre>
  
  <p>finally I create session like</p>
  
  <pre><code>SessionFactory factory = new AnnotationConfiguration().addPackage("models").addAnnotatedClass(MSISDN.class).buildSessionFactory();
          Session session = factory.openSession();
  </code></pre>