title: JPA: java.lang.IllegalArgumentException: Not an entity
body: <p>I wrote a simple Java that uses POJOs, servlets, JSPs. I am using:</p>
  
  <ul>
  <li>Tomcat 7.0.16</li>
  <li>Oracle 11g</li>
  <li>Oracle Java build 1.6.0_26-b03</li>
  </ul>
  
  <p>I use ivy to resolve my dependencies:</p>
  
  <pre><code>    &lt;dependency org="oracle" name="ojdbc6" rev="11g" conf="default -&gt; default" /&gt;
  
      &lt;dependency org="org.hibernate" name="hibernate-commons-annotations" rev="3.2.0.Final" conf="compile -&gt; runtime" /&gt;
      &lt;dependency org="org.hibernate" name="hibernate-annotations" rev="3.5.6-Final" conf="default -&gt; runtime" /&gt;
      &lt;dependency org="org.hibernate" name="hibernate-core" rev="3.6.5.Final" conf="default -&gt; runtime" /&gt;
      &lt;dependency org="org.hibernate" name="hibernate-validator" rev="4.0.2.GA" conf="runtime -&gt; runtime" /&gt;
      &lt;dependency org="org.hibernate.javax.persistence" name="hibernate-jpa-2.0-api" rev="1.0.1.Final" conf="compile -&gt; default" /&gt;
      &lt;dependency org="org.hibernate" name="hibernate-entitymanager" rev="3.6.5.Final" conf="compile -&gt; default" /&gt;
  </code></pre>
  
  <p>My POJO Vehicle contains the following annotations:</p>
  
  <pre><code>import java.io.Serializable;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.Version;
  
  @Entity
  public class Vehicle implements Serializable{
  
  
      /**
       * 
       */
      private static final long serialVersionUID = 8560417193012227968L;
  
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      private Long identifier;
  
      private String serialNumber;
      private String model;
      private String manufacturer;
      private int year;
      private String condition;
  
      @Version
      private long version;
  
      public Vehicle(){
      }
  </code></pre>
  
  <p>When I run my code, I get the following:</p>
  
  <pre><code>2013-10-28 11:40:50 ERROR SqlVehicleService:42 - java.lang.IllegalArgumentException: Not an entity: class com.foo.demos.car.model.Vehicle
  java.lang.IllegalArgumentException: Not an entity: class com.foo.demos.car.model.Vehicle
      at org.hibernate.ejb.metamodel.MetamodelImpl.entity(MetamodelImpl.java:160)
      at org.hibernate.ejb.criteria.QueryStructure.from(QueryStructure.java:138)
      at org.hibernate.ejb.criteria.CriteriaQueryImpl.from(CriteriaQueryImpl.java:179)
      at com.foo.demos.car.impl.SqlVehicleService.getVehicles(SqlVehicleService.java:37)
      at org.apache.jsp.secured.vehicles_jsp._jspService(vehicles_jsp.java:194)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:572)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:403)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:301)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:162)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
  </code></pre>
  
  <p>My <code>persistence.xml</code> does not contain any information about Vehicle. My understanding is that annotations are enough. Is that correct?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence 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_1_0.xsd"
   version="1.0"&gt;
  
   &lt;persistence-unit name="cardemo"&gt;
    &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
    &lt;!-- the JNDI data source --&gt;
    &lt;non-jta-data-source&gt;java:comp/env/jdbc/cardemo&lt;/non-jta-data-source&gt;
    &lt;properties&gt;
   &lt;property name="javax.persistence.validation.mode" value="NONE" /&gt;
     &lt;!-- if this is true, hibernate will print (to stdout) the SQL it executes, 
      so you can check it to ensure it"s not doing anything crazy --&gt;
     &lt;property name="hibernate.show_sql" value="true" /&gt;
     &lt;property name="hibernate.format_sql" value="true" /&gt;
     &lt;!-- since most database servers have slightly different versions of the 
      SQL, Hibernate needs you to choose a dialect so it knows the subtleties of 
      talking to that server --&gt;
     &lt;property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" /&gt;
     &lt;!-- this tell Hibernate to update the DDL when it starts, very useful 
      for development, dangerous in production --&gt;
     &lt;property name="hibernate.hbm2ddl.auto" value="update" /&gt;
    &lt;/properties&gt;
   &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>I obviously overlooked something. What's that? What am I missing?</p>