title: 'java.lang.NoSuchFieldError' while using the JPA
body: <p>I am getting the following error while trying out this <a href="http://schuchert.wikispaces.com/JPA+Tutorial+1+-+Getting+Started" rel="nofollow">JPA tutorial</a>:</p>
  
  <pre><code>java.lang.NoSuchFieldError: NONE
      at org.hibernate.ejb.QueryImpl.&lt;init&gt;(QueryImpl.java:609)
      at org.hibernate.ejb.QueryImpl.&lt;init&gt;(QueryImpl.java:80)
      at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:272)
      at entity.PersonTest.insertAndRetrieve(PersonTest.java:50)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  </code></pre>
  
  <p>Here is my <strong>persistence.xml</strong>:</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_2_0.xsd"
      version="2.0"&gt;
  
      &lt;persistence-unit name="examplePersistenceUnit" transaction-type="RESOURCE_LOCAL"&gt;
          &lt;class&gt;entity.Person&lt;/class&gt;
          &lt;properties&gt;
              &lt;property name="hibernate.show_sql" value="false" /&gt;
              &lt;property name="hibernate.format_sql" value="false" /&gt;
  
              &lt;property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" /&gt;
              &lt;property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/jpa_test" /&gt;
              &lt;property name="hibernate.connection.username" value="root" /&gt;
              &lt;property name="hibernate.connection.password" value="admin" /&gt;
  
              &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /&gt;
              &lt;property name="hibernate.hbm2ddl.auto" value="create" /&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p><strong>Person.java</strong></p>
  
  <pre><code>   package entity;
  
      import javax.persistence.Entity;
      import javax.persistence.GeneratedValue;
      import javax.persistence.Id;
      import javax.persistence.Table;
  
      @Entity 
      public class Person {
  
          @Id
          @GeneratedValue
          private int id;
          private String firstName;
          private char middleInitial;
          private String lastName;
          private String streetAddress1;
          private String streetAddress2;
          private String city;
          private String state;
          private String zip;
  
      .
      .
      .
      (getters and setters)
  </code></pre>
  
  <p>Part of my JUnit Test file:</p>
  
  <pre><code>@SuppressWarnings("unchecked")
      @Test
      public void insertAndRetrieve() {
          em.getTransaction().begin();
          em.persist(p1);
          em.persist(p2);
          em.getTransaction().commit();
  
          final List&lt;Person&gt; list = em.createQuery("select p from Person p")
                  .getResultList();
          System.out.println("here...");
  
          assertEquals(2, list.size());
  </code></pre>
  
  <p>I am using MySQL db, the 'person' table is present in the database. And after </p>
  
  <pre><code>em.getTransaction().begin();
  em.persist(p1);
  em.persist(p2);
  em.getTransaction().commit();
  </code></pre>
  
  <p><strong>I can see the two records are inserted in the person table. But on the next statement, it fails.</strong></p>
  
  <p><strong>EDIT 1:</strong> 
  JARs in my build path: </p>
  
  <pre><code>antlr-2.7.6.jar, 
  commons-collections-3.1.jar, 
  dom4j-1.6.1.jar, hibernate3.jar, 
  hibernate-annotations-3.5.5-Final.jar, 
  hibernate-commons-annotations-3.2.0.Final.jar, 
  hibernate-entitymanager-3.5.5-Final.jar, 
  hibernate-entitymanager-3.5.5-Final-sources.jar, 
  javaee-api-5.0-3.jar, 
  javassist-3.9.0.GA.jar, 
  log4j-1.2.12.jar, 
  mysql-connector-java-5.1.15.jar, 
  slf4j-api-1.6.1.jar, 
  slf4j-simple-1.6.1.jar, 
  hibernate-jpa-2.0-api-1.0.0-CR-1.jar
  </code></pre>
  
  <p>Can anyone tell me what I am doing wrong?</p>
  
  <p>Thanks.</p>