title: Tomcat does not connect to the database, but when I run it from within netbeans works perfectly
body: <p>I'm using Java + BlazeDS + MySQL + Flash Builder + EclipseLink (JPA 2.1) + Tomcat 7 (Windows)</p>
  
  <p>The problem is this, when I compile my application within Netbeans the connection to the database works perfectly. But when I do a deploy directly in tomcat with war file it does not access the database.</p>
  
  <p>I tried with multiple versions of tomcat, including tomcat netbeans and it did not work. Only works when I run the project from within Netbeans</p>
  
  <p>I'm almost mad trying to solve it, someone has gone through this problem?</p>
  
  <p>I really appreciate any help</p>
  
  <p>My persistence.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&gt;
  &lt;persistence-unit name="goncricPU" transaction-type="RESOURCE_LOCAL"&gt;
  &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;    
  &lt;class&gt;entidade.sancric&lt;/class&gt;
  &lt;class&gt;entidade.logincric&lt;/class&gt;    
  &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt;
  &lt;properties&gt;
  &lt;property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/derea?   zeroDateTimeBehavior=convertToNull"/&gt;
  &lt;property name="javax.persistence.jdbc.password" value="qwaszx"/&gt;
  &lt;property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/&gt;
  &lt;property name="javax.persistence.jdbc.user" value="derea"/&gt;
  &lt;property name="eclipselink.ddl-generation" value="create-tables"/&gt;
  &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>.......</p>
  
  <p>File that makes the persistence in database:</p>
  
  <pre><code> */
  public class persistir {
  EntityManagerFactory emf = Persistence.createEntityManagerFactory("goncricPU");
  
  public void persist(Object object) {
      EntityManager em = emf.createEntityManager();
      try {
          em.getTransaction().begin();
          em.persist(object);
          em.getTransaction().commit();
      } catch (Exception e) {
             Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught",   e);
          em.getTransaction().rollback();
      } finally {
          em.close();
      }
     }   
  
  }
  </code></pre>