title: java.lang.ClassNotFoundException: org.dom4j.DocumentException
body: <p>I made some code to learn hibernate. It is throwing the error below. How do I find out what the problem is and fix it ? dom4j sounds like an XML problem. hibernate.cfg.xml is the problem ?</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
  at com.examscam.model.User.persist(User.java:45)
  at com.examscam.model.User.main(User.java:57)
  Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  ... 2 more
  </code></pre>
  
  <p><strong>(why is eclipse not showing this "2more" thing ?)</strong></p>
  
  <p><strong>Code -</strong> </p>
  
  <pre><code>package com.examscam.model;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import org.hibernate.cfg.AnnotationConfiguration;
  import org.hibernate.tool.hbm2ddl.SchemaExport;
  
  
  @Entity
  public class User {
  
  private Long id;
  private String password;
  
  @Id
  @GeneratedValue
  
  public Long getId(){
      return id;
  
  }
  
  public void setId(Long id){
  
      Class c1 = User.class;
      this.id = id;
  
  }
  
  public String getPassword() {
      return password;
  }
  
  public void setPassword(String password) {
      this.password = password;
  }
  
  public static void persist(){
  
      /* 
       * Contains all the info needed to connect to database, along with
       * info from your JPA annotated class, ie this class. 
      */
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(User.class);
      config.configure();
  
      SchemaExport schemaExport = new SchemaExport(config);
      schemaExport.create(true, true);
  
  }
  
  
  public static void main(String[]args){
  
      persist();
  
  }
  
  }
  </code></pre>
  
  <p><strong>XML file -</strong> </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;property name = "connection.url"&gt;
  jdbc:mysql://localhost/examscam
  &lt;/property&gt;
  
  &lt;property name = "connection.username"&gt;
  root
  &lt;/property&gt;
  
  &lt;property name = "connection.password"&gt;
  password
  &lt;/property&gt;
  
  &lt;property name = "connection.driver_class"&gt;
  com.mysql.jdbc.Driver
  &lt;/property&gt;
  
  &lt;property name = "dialect"&gt;
  org.hibernate.dialect.MySQLDialect
  &lt;/property&gt;
  
  &lt;property name = "transaction.factory_class"&gt;
  org.hibernate.transaction.JDBCTransactionFactory
  &lt;/property&gt;
  
  &lt;property name = "current_session_context_class"&gt;
  thread
  &lt;/property&gt;
  
  &lt;!-- this will show us all the SQL statements--&gt;
  
  &lt;property name = "hibernate.show_sql"&gt;
  true
  &lt;/property&gt;
  
  &lt;!-- We dont use any mapping files as of now--&gt;
  
  &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p><strong>After fixing the above errors, there is a new problem -</strong> </p>
  
  <p>I am making code with eclipse. I added all the possible jars needed for the code and my code is still not working. Why is this error <strong>java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder</strong> occurring when i already added sl4fj (
  slf4j-api-1.5.8.jar) to build path ?</p>
  
  <p>The error - </p>
  
  <pre><code>  SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j   
    /impl/StaticLoggerBinder
  at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:223)
  at org.slf4j.LoggerFactory.bind(LoggerFactory.java:120)
  at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111)
  at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:269)
  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)
  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255)
  at org.hibernate.cfg.Configuration.&lt;clinit&gt;(Configuration.java:152)
  at com.examscam.model.User.persist(User.java:45)
  at com.examscam.model.User.main(User.java:57)
     Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  ... 9 more
  </code></pre>