java - AbstractMethodError thrown at runtime with Hibernate/JPA -


i absolutely new hibernate , jpa , have following problem trying implement tutorial uses hibernate following jpa specification.

i have these classes:

1) helloworldclient class, entry point of application, containing main method:

package client;  import javax.persistence.entitymanager; import javax.persistence.entitymanagerfactory; import javax.persistence.entitytransaction; import javax.persistence.persistence;  import entity.message;  public class helloworldclient {     public static void main(string[] args) {          entitymanagerfactory emf = persistence.createentitymanagerfactory("merging");          entitymanager em = emf.createentitymanager();         entitytransaction txn = em.gettransaction();         txn.begin();          message message = new message("hello"); //transient state                 em.persist(message); //persistent state                  txn.commit();            em.close();           message.settext("hi"); //modifying detached state of message          entitymanager em2 = emf.createentitymanager();         entitytransaction txn2 = em2.gettransaction();         txn2.begin();          //the returned mergedmessage persistent object         //any changes mergedmessage dirty checked when txn2 committed , updated in database         message mergedmessage = em2.merge(message);          txn2.commit();         em2.close();                   //detaching objects explicitly         /*         entitymanager em3 = emf.createentitymanager();         entitytransaction txn3 = em.gettransaction();         txn3.begin();          message msg = new message("howdy"); //transient state                 em.persist(msg); //persistent state              em.detach(msg); //detaching message object explicitly         txn3.commit();         em3.close();         */        } } 

2) message entity class mapped on database table:

package entity;  import javax.persistence.column; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.generationtype; import javax.persistence.id; import javax.persistence.table;  @entity @table(name="message") public class message {      @id     @generatedvalue(strategy=generationtype.auto)     @column(name="id")       private long id;      @column(name="text")         private string text;      public message() {}     public message(string text) {         this.text = text;     }      public void settext(string text) {         this.text = text;     }  } 

3) , have persistence.xml configuration file in meta-inf folder of application:

<?xml version="1.0" encoding="utf-8"?> <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" xmlns="http://java.sun.com/xml/ns/persistence">      <persistence-unit name="merging" transaction-type="resource_local">         <properties>              <!-- database connection settings -->             <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.driver" />             <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/hello-world" />             <property name="javax.persistence.jdbc.user" value="root" />             <property name="javax.persistence.jdbc.password" value="mypassword" />              <!-- sql dialect -->             <property name="hibernate.dialect" value="org.hibernate.dialect.mysqldialect" />              <!-- create/update tables automatically using mapping metadata -->             <property name="hibernate.hbm2ddl.auto" value="update" />              <!-- pretty print sql in log file , console -->             <property name="hibernate.format_sql" value="true" />         </properties>      </persistence-unit> </persistence> 

when try run application, obtain error message in stacktrace:

picked java_tool_options: -javaagent:/usr/share/java/jayatanaag.jar  exception in thread "main" java.lang.abstractmethoderror: org.hibernate.jpa.boot.internal.entitymanagerfactorybuilderimpl$4.getconfigurationvalues()ljava/util/map;     @ org.hibernate.boot.registry.classloading.internal.classloaderserviceimpl.withtccl(classloaderserviceimpl.java:404)     @ org.hibernate.jpa.boot.internal.entitymanagerfactorybuilderimpl.build(entitymanagerfactorybuilderimpl.java:842)     @ org.hibernate.jpa.hibernatepersistenceprovider.createentitymanagerfactory(hibernatepersistenceprovider.java:75)     @ org.hibernate.ejb.hibernatepersistence.createentitymanagerfactory(hibernatepersistence.java:54)     @ javax.persistence.persistence.createentitymanagerfactory(persistence.java:55)     @ javax.persistence.persistence.createentitymanagerfactory(persistence.java:39)     @ client.helloworldclient.main(helloworldclient.java:14) 

i've had same issue when trying hibernate tutorials. means there compatibility issues between jar files added build path.

in case, seem org.hibernate.jpa.boot.internal.entitymanagerfactorybuilderimpl.getconfigurationvalues() appears in latest version abstract method, hence above error. try changing jpa jar previous version, solve issue; that's helped in case.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -