title: Table/View does not exist in JavaEE web app deployed on Glassfish
body: <p>I tried to deploy a JavaEE Web app with JPA persistence on a Glassfish server I installed on an Amazon EC2 instance. Everything worked fine for the deployment and for web pages rendering in my browser, but when I try to use persistence the result is the error "Table/View 'ATHLETE' does not exist'.</p>
  
  <p>This is the first time I try to develop a web app with JPA and I'm trying to create a skeleton to use in the future for we app, but I think I'm missing a fundamental part. Also, using @GeneratedValue for the @Id I get a SEQUENCE table missing error. I'm afraid the two problems are related</p>
  
  <p>The Athlete.java</p>
  
  <pre><code>package com.storassa.javaee.scuolesci;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.NamedQuery;
  
  
  @Entity
  @NamedQuery(name = "findAllAthletes", query = "SELECT b FROM Athlete b")
  public class Athlete {
  
          static int idRaw; // I use this to avoid the @GeneratedValue issue
  
          @Id
          int id;
          String name, surname;
          int birth;
  
          public Athlete () {
                  idRaw++;
                  id = idRaw;
          }
  
         &lt;getters and setters&gt;
  }
  </code></pre>
  
  <p>The AthleteEjb.java</p>
  
  <pre><code>package com.storassa.javaee.scuolesci;
  
  import java.util.List;
  
  import javax.ejb.LocalBean;
  import javax.ejb.Startup;
  import javax.ejb.Stateless;
  import javax.persistence.EntityManager;
  import javax.persistence.PersistenceContext;
  import javax.persistence.Query;
  import javax.annotation.sql.*;
  
  @LocalBean
  @Stateless
  public class AthleteEJB {
  
          @PersistenceContext(unitName="scuoleSciPU")
          private EntityManager em;
  
          public List&lt;Athlete&gt; findAthlete() {
                  Query query = em.createNamedQuery("findAllAthletes");
                  return query.getResultList();
          }
  
          public Athlete createAthlete(Athlete athlete) {
                  em.persist(athlete);
                  return athlete;
          }
  }
  </code></pre>
  
  <p>The persistence.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
          version="2.1"&gt;
          &lt;persistence-unit name="scuoleSciPU" transaction-type="JTA"&gt;
                  &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;
                  &lt;class&gt;com.storassa.javaee.scuolesci.Athlete&lt;/class&gt;
                  &lt;properties&gt;
                          &lt;property name="eclipselink.target-database" value="DERBY" /&gt;
                          &lt;property name="eclipselink.jdbc.driver" 
                                  value="org.apache.derby.jdbc.ClientDriver" /&gt;
                          &lt;property name="eclipselink.jdbc.url"
                                  value="jdbc:derby://localhost:1527;create=true" /&gt;
                          &lt;property name="eclipselink.jdbc.user" value="APP" /&gt;
                          &lt;property name="eclipselink.jdbc.password" value="APP" /&gt;
                          &lt;property name="eclipselink.ddl-generation" value=" drop-and-create-tables" /&gt;
                          &lt;property name="eclipselink.logging.level" value="INFO" /&gt;
                          &lt;property name="eclipselink.deploy-on-startup" value="true" /&gt;
                  &lt;/properties&gt;
          &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>The error returned on the browser</p>
  
  <pre><code>type Exception report
  
  message Internal Server Error
  
  description The server encountered an internal error that prevented it from fulfilling this request.
  
  exception
  
  javax.servlet.ServletException: javax.ejb.EJBException: Transaction aborted
  
  root cause
  
  javax.faces.el.EvaluationException: javax.ejb.EJBException: Transaction aborted
  
  root cause
  
  javax.ejb.EJBException: Transaction aborted
  
  root cause
  
  javax.transaction.RollbackException: Transaction marked for rollback.
  
  root cause
  
  javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
  Internal Exception: java.sql.SQLSyntaxErrorException: Table/View 'ATHLETE' does not exist.
  Error Code: -20001
  Call: INSERT INTO ATHLETE (ID, BIRTH, NAME, SURNAME) VALUES (?, ?, ?, ?)
      bind =&gt; [4 parameters bound]
  Query: InsertObjectQuery(com.storassa.javaee.scuolesci.Athlete@65fd5648)
  
  root cause
  
  Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
  Internal Exception: java.sql.SQLSyntaxErrorException: Table/View 'ATHLETE' does not exist.
  Error Code: -20001
  Call: INSERT INTO ATHLETE (ID, BIRTH, NAME, SURNAME) VALUES (?, ?, ?, ?)
      bind =&gt; [4 parameters bound]
  Query: InsertObjectQuery(com.storassa.javaee.scuolesci.Athlete@65fd5648)
  
  root cause
  
  java.sql.SQLSyntaxErrorException: Table/View 'ATHLETE' does not exist.
  
  root cause
  
  org.apache.derby.client.am.SqlException: Table/View 'ATHLETE' does not exist.
  </code></pre>
  
  <p>I don't provide web-related resource/classes as I don't think they can be useful. In case let me know.</p>
  
  <p>Should the table ATHLETE be created due to the @Entity annotation and the ?</p>