title: ClassNotFoundException: javax.persistence.Persistence - Hibernate
body: <p>I'm getting this error:
  java.lang.ClassNotFoundException: javax.persistence.Persistence</p>
  
  <p>This is my project:</p>
  
  <p>persistence.xml</p>
  
  <pre><code>&lt;persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"&gt;
     &lt;persistence-unit name="Forum"&gt;
         &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
             &lt;class&gt;Model.Section&lt;/class&gt;
                 &lt;properties&gt;
                     &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /&gt;
                     &lt;property name="hibernate.hbm2ddl.auto" value="update" /&gt;
                     &lt;property name="hibernate.show_sql" value="true" /&gt;
                     &lt;property name="hibernate.format_sql" value="true" /&gt;
                     &lt;property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" /&gt;
                     &lt;property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/Forum" /&gt;
                     &lt;property name="javax.persistence.jdbc.user" value="root" /&gt;
                     &lt;property name="javax.persistence.jdbc.password" value="root" /&gt;
                 &lt;/properties&gt;
     &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>NewSectionController.java</p>
  
  <pre><code>package Controller;
  
  import java.io.IOException;
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import Model.Section;
  
  public class NewSectionController extends HttpServlet {
      private static final long serialVersionUID = 1L;
  
      public NewSectionController() {
          super();
      }
  
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          RequestDispatcher rs = request.getRequestDispatcher("newSection.jsp");
          rs.forward(request, response);
      }
  
      protected void doPost(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
  
          String title = request.getParameter("titulo");
          String description = request.getParameter("descricao");
          Section section = new Section();
          section.insertNewSection(title, description);
      }
  
  }
  </code></pre>
  
  <p>Section.java</p>
  
  <p>package Model;</p>
  
  <pre><code>import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.EntityManager;
  import javax.persistence.EntityManagerFactory;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.Persistence;
  
  @Entity
  public class Section {
  
      @Id
      @GeneratedValue
      int idSection;
      @Column
      String titleSection;
      @Column
      String descriptionSection;
  
      public void insertNewSection(String title, String description) {
          EntityManagerFactory factory = Persistence.createEntityManagerFactory("Forum");
          EntityManager em = factory.createEntityManager();
  
          Section section = new Section();
          section.setTitleSection(title);
          section.setDescriptionSection(description);
  
          em.getTransaction().begin();
          em.persist(section);
          em.getTransaction().commit();
      }
  
      public int getIdSection() {
          return idSection;
      }
      public void setIdSection(int idSection) {
          this.idSection = idSection;
      }
      public String getTitleSection() {
          return titleSection;
      }
      public void setTitleSection(String titleSection) {
          this.titleSection = titleSection;
      }
      public String getDescriptionSection() {
          return descriptionSection;
      }
      public void setDescriptionSection(String descriptionSection) {
          this.descriptionSection = descriptionSection;
      }
  }
  </code></pre>
  
  <p>The files are organized this way:</p>
  
  <pre><code>src/Controller/NewSectionController.java
  src/Model/Section.java
  src/META-INF/persistence.xml
  resources/log4j.properties
  lib/
  WebContent/
  </code></pre>
  
  <p>And I have imported and add to build path all these libs:</p>
  
  <pre><code>antlr-2.7.7.jar
  c3p0-0.9.1.jar
  dom4j-1.6.1.jar
  ehcache-core-2.4.3.jar
  hibernate-c3p0-4.2.2.Final.jar
  hibernate-commons-annotations-4.0.2.Final.jar
  hibernate-core-4.2.2.Final.jar
  hibernate-ehcache-4.2.2.Final.jar
  hibernate-entitymanager-4.2.2.Final.jar
  hibernate-envers-4.2.2.Final.jar
  hibernate-infinispan-4.2.2.Final-tests.jar
  hibernate-infinispan-4.2.2.Final.jar
  hibernate-jpa-2.0-api-1.0.1.Final.jar
  hibernate-proxool-4.2.2.Final.jar
  infinispan-core-5.2.0.Beta3.jar
  javassist-3.15.0-GA.jar
  jboss-logging-3.1.0.GA.jar
  jboss-logging-3.1.1.GA.jar
  jboss-marshalling-1.3.15.GA.jar
  jboss-marshalling-river-1.3.15.GA.jar
  jboss-transaction-api_1.1_spec-1.0.1.Final.jar
  jgroups-3.2.0.CR1.jar
  proxool-0.8.3.jar
  rhq-pluginAnnotations-3.0.4.jar
  slf4j-api-1.6.1.jar
  stax2-api-3.1.1.jar
  staxmapper-1.1.0.Final.jar
  woodstox-core-asl-4.1.1.jar
  </code></pre>
  
  <p>And I'm still getting the java.lang.ClassNotFoundException: javax.persistence.Persistence error.</p>
  
  <p>What should I do?</p>