Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6030931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:06:38+00:00 2026-05-23T05:06:38+00:00

I am getting the following error while trying out this JPA tutorial : java.lang.NoSuchFieldError:

  • 0

I am getting the following error while trying out this JPA tutorial:

java.lang.NoSuchFieldError: NONE
    at org.hibernate.ejb.QueryImpl.<init>(QueryImpl.java:609)
    at org.hibernate.ejb.QueryImpl.<init>(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)

Here is my persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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">

    <persistence-unit name="examplePersistenceUnit" transaction-type="RESOURCE_LOCAL">
        <class>entity.Person</class>
        <properties>
            <property name="hibernate.show_sql" value="false" />
            <property name="hibernate.format_sql" value="false" />

            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
            <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/jpa_test" />
            <property name="hibernate.connection.username" value="root" />
            <property name="hibernate.connection.password" value="admin" />

            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
            <property name="hibernate.hbm2ddl.auto" value="create" />
        </properties>
    </persistence-unit>
</persistence>

Person.java

   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)

Part of my JUnit Test file:

@SuppressWarnings("unchecked")
    @Test
    public void insertAndRetrieve() {
        em.getTransaction().begin();
        em.persist(p1);
        em.persist(p2);
        em.getTransaction().commit();

        final List<Person> list = em.createQuery("select p from Person p")
                .getResultList();
        System.out.println("here...");

        assertEquals(2, list.size());

I am using MySQL db, the ‘person’ table is present in the database. And after

em.getTransaction().begin();
em.persist(p1);
em.persist(p2);
em.getTransaction().commit();

I can see the two records are inserted in the person table. But on the next statement, it fails.

EDIT 1:
JARs in my build path:

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

Can anyone tell me what I am doing wrong?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:06:38+00:00Added an answer on May 23, 2026 at 5:06 am

    Remove the ejb3-persistence.jar JAR file from the class path. It contains the interfaces of the JPA 1.0 specification. You’ll need to retain the hibernate-jpa-2.0-api-1.0.0-CR-1.jar JAR file, for it contains the interfaces for the JPA 2.0 specification.

    Note: If you need to work against JPA 1.0, then do not use Hibernate 3.5.5 for it contains the JPA 2.0 implementation. In the future, use Maven for dependency management; it will help you avoid these issues.

    Addendum:

    If I were to setup Hibernate EntityManager 3.5.5 (JPA 2) from scratch, these would be the files I would consider. The following list has been inferred from the Hibernate documentation :

    • hibernate3.jar
    • hibernate-jpa-2.0-api-1.0.0.Final.jar
    • antlr-2.7.6.jar
    • commons-collections-3.1.jar
    • dom4j-1.6.1.jar
    • javassist-3.9.0.GA.jar
    • jta-1.1.jar
    • slf4j-api-1.5.8.jar and either of
      • cglib-2.2.jar, or
      • javassist-3.9.0.GA.jar

    The last two haven’t been mentioned in the documentation, but are required. I don’t see the need for any of the other JARs, except for mysql-connector-java-5.1.15.jar and log4j-1.2.12.jar (both of which could be retained).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm continually getting the following error under Eclipse Galileo while trying to install the
I have done simple java app for blackberry, while building am getting following error.
I am getting the following error while trying to add a NOT NULL column
I'm getting the following error message in my httpd error log while trying to
I'm getting the following error from g++ while trying to add iterator support for
I'm getting the following error message in Chrome and firefox while trying to implement
I am getting the following error while trying to install heroku. arun@laptop:~/apps/pm$ sudo gem
I keep getting this writing to a closed file error while trying to compile
I am getting following error while trying to connect to a sftp server:- ncftpput:
I am getting the following error while compiling a sample program in Qt 4.5

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.