title: [Hibernate]Error: entity class not found:
body: <p>I get tired of this for a long time. I do not know what caused this error. Here are my files:</p>
  
  <p>Uzytkownik.hbm.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                     "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
  &lt;hibernate-mapping&gt;
   &lt;class name="Uzytkownik" table="uzytkownicy"&gt;
    &lt;id column="id" name="id" type="int"/&gt;
    &lt;property column="login" generated="never" lazy="false" name="login" type="string"/&gt;
    &lt;property column="haslo" generated="never" lazy="false" name="haslo" type="string"/&gt;
   &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <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 name=""&gt;
    &lt;property name="hibernate.connection.driver_class"&gt;org.gjt.mm.mysql.Driver&lt;/property&gt;
    &lt;property name="hibernate.connection.password"&gt;root&lt;/property&gt;
    &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://localhost/sprawozdania&lt;/property&gt;
    &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
    &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5Dialect&lt;/property&gt;
    &lt;mapping resource="com/vaannila/uzytkownik/Uzytkownik.hbm.xml"/&gt;
   &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>I use mysql 5.5.</p>
  
  <p>I get the following error:</p>
  
  <pre><code> Exception in thread "main" java.lang.ExceptionInInitializerError
      at com.vaannila.util.HibernateUtil.&lt;clinit&gt;(HibernateUtil.java:14)
      at com.vaannila.uzytkownik.Main.saveUzyt(Main.java:22)
      at com.vaannila.uzytkownik.Main.main(Main.java:16)
  Caused by: org.hibernate.MappingException: entity class not found: Uzytkownik
  </code></pre>
  
  <p>This are my classes: 
  main.java</p>
  
  <pre><code>package com.vaannila.uzytkownik;
  
  import org.hibernate.HibernateException;
  import org.hibernate.Session;
  import org.hibernate.Transaction;
  
  import javax.persistence.Entity;
  import com.vaannila.util.HibernateUtil;
  public class Main {
  
      /**
       * @param args
       */
      public static void main(String[] args) {
          Main obj = new Main();
          String uzytkownikLogin = obj.saveUzyt("Adam", "Malysz");
  
      }
  
  
      public String saveUzyt(String login, String haslo){
          Session session = HibernateUtil.getSessionFactory().openSession();
          Transaction transaction = null;
          String uzytLog = null;
          try {
              transaction = session.beginTransaction();
              Uzytkownik uzyt = new Uzytkownik();
              uzyt.setLogin(login);
              uzyt.setHaslo(haslo);
              uzytLog = (String) session.save(uzyt);
              transaction.commit();
          } catch (HibernateException e) {
              transaction.rollback();
              e.printStackTrace();
          } finally {
              session.close();
          }
          return uzytLog;
      }
  
  
  
  }
  </code></pre>
  
  <p>Uzytkownik.java:</p>
  
  <pre><code>package com.vaannila.uzytkownik;
  // default package
  // Generated 2011-07-14 13:39:18 by Hibernate Tools 3.4.0.CR1
  
  /**
   * Uzytkownik generated by hbm2java
   */
  public class Uzytkownik implements java.io.Serializable {
  
      private int id;
      private String login;
      private String haslo;
  
      public Uzytkownik() {
      }
  
      public Uzytkownik(int id) {
          this.id = id;
      }
  
      public Uzytkownik(int id, String login, String haslo) {
          this.id = id;
          this.login = login;
          this.haslo = haslo;
      }
  
      public int getId() {
          return this.id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public String getLogin() {
          return this.login;
      }
  
      public void setLogin(String login) {
          this.login = login;
      }
  
      public String getHaslo() {
          return this.haslo;
      }
  
      public void setHaslo(String haslo) {
          this.haslo = haslo;
      }
  
  }
  </code></pre>
  
  <p>HibernateUtil.java:</p>
  
  <pre><code>package com.vaannila.util;
  
  import org.hibernate.SessionFactory;
  import org.hibernate.cfg.Configuration;
  
  
      public class HibernateUtil {
          private static final SessionFactory sessionFactory;
          static {
              try {
                  sessionFactory = new Configuration().configure().buildSessionFactory();
              } catch (Throwable ex) {
                  System.err.println("Initial SessionFactory creation failed." + ex);
                  throw new ExceptionInInitializerError(ex);
  
              }
  
          }
          public static SessionFactory getSessionFactory() {
              return sessionFactory;
          }
  
  }
  </code></pre>