title: Javaee, postgresql and tomcat
body: <p>I'm studing javaee and Im executing the project in ubuntu server with tomcat and postgres.
  When I try to execute the servlet , I have this error:</p>
  
  <pre><code>java.lang.ClassNotFoundException: javax.persistence.EntityTransaction
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
      ejemploLoginMVC.Modelo.Conexion.crearla(Conexion.java:50)
      ejemploLoginMVC.Controller.nuevoUsuario.doPost(nuevoUsuario.java:47)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
  </code></pre>
  
  <p>usuario.java</p>
  
  <pre><code>@Entity
  
  public class Usuario {
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      private int id_Usuario;
      @Column(nullable=false)
      private String nick;
      @Column(nullable=false)
      private String password;
  
      public String getNick() {
          return nick;
      }
      public void setNick(String nick) {
          this.nick = nick;
      }
      public String getPassword() {
          return password;
      }
      public void setPassword(String password) {
          this.password = password;
      }
  
  
  
  }
  </code></pre>
  
  <p>Conexion.java</p>
  
  <pre><code>public class Conexion {
  
      private static EntityManagerFactory emf;
      private static EntityManager em;
      private static EntityTransaction tx;
  
      String nick;
      String pass;
      public Conexion(String nick,String pass){
          this.nick=nick;
          this.pass=pass;
      }
  
      @BeforeClass
      public static void initEntityManager() throws Exception {
          emf = Persistence.createEntityManagerFactory("usuarios-unit");
          em = emf.createEntityManager();
      }
  
      @AfterClass
      public static void closeEntityManager() throws SQLException {
          if (em != null) em.close();
          if (emf != null) emf.close();
      }
  
      @Before
      public void initTransaction() {
          tx = em.getTransaction();
      }
  
      public void crearla() throws Exception{
  
          Usuario usuario=new Usuario();
          usuario.setNick(nick);
          usuario.setPassword(pass);
  
          tx.begin();
          em.persist(usuario);
          tx.commit();
  
          em.close();
          emf.close();
      }
  
  }
  </code></pre>
  
  <p>nuevoUsuario.java (servlet)</p>
  
  <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  // TODO Auto-generated method stub
  response.setContentType("text/html;charset=UTF-8");
  
  String nick = request.getParameter("nick");
  String pass = request.getParameter("pass");
  Conexion conexion= new Conexion(nick,pass);
  try {
      conexion.crearla();
  } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
  try(PrintWriter out =response.getWriter()){
  
      out.println("&lt;!DOCTYPE html&gt;");
      out.println("&lt;html&gt;");
      out.println("&lt;head&gt;");
      out.println("&lt;/head&gt;");
      out.println("&lt;body&gt;");
      out.println("&lt;p&gt;USUARIO:"+nick+"&lt;/p&gt;");
      out.println("&lt;p&gt;PASSWORD:"+pass+"&lt;/p&gt;");
  
      out.println("&lt;/body&gt;");
      out.println("&lt;/html&gt;");
  </code></pre>
  
  <p>}</p>
  
  <p>I cant find the error, i added to the project: postgresql-jdbc4.jar , javaee-api-6.0 , tomcat jars , tomee jars ,etc </p>
  
  <p>Thanks :D</p>