java.lang.NoSuchFieldError: NONE I am getting this run time exception when I am running my hello world program using JPA . The code is as mentioned below -- // Second unit of work EntityManager newEm = emf.createEntityManager(); EntityTransaction newTx = newEm.getTransaction(); newTx.begin(); //Exception is thrown at this point List messages = newEm.createQuery("select m from Message m order by m.text asc").getResultList(); for (Object m : messages) { Message loadedMsg = (Message) m; System.out.println(loadedMsg.getText()); } newTx.commit(); newEm.close(); }catch(Exception e){e.printStackTrace();} // Shutting down the application emf.close(); } The jars which I am using are mentioned below -- 1)ejb3-persistence-1.0.2.GA 2)hibernate3 3)hibernate-entitymanager-3.5.1-Final 4)hibernate-jpa-2.0-api-1.0.0.Final 5)hibernate-validator-4.0.2.GA Database which I am using is hsqldb I will be very much obliged for the solution of the same , I feel that it is related to versions of the jars but not sure which one to use.
以上内容摘自网络:
List<User> ls = em.createNativeQuery("select * from users").getResultList();
在执行到如上代码的时候抛出一个异常:
原因是 jar包重复了, 原来我既导入了 JavaEE 5 又单独导入了 java-persistence-api
删除 JavaEE5 问题解决