I wrote my first hibernate project exactly as same as my teacher did but I got this exception :
> Exception in thread "main" java.lang.ExceptionInInitializerError
> Caused by: javax.persistence.PersistenceException: No Persistence
> provider for EntityManager named Sharif: Provider named
> org.hibernate.jpa.HibernatePersistenceProvider threw unexpected
> exception at create EntityManagerFactory: java.lang.NoSuchMethodError
> java.lang.NoSuchMethodError:
> javax.persistence.Table.indexes()[Ljavax/persistence/Index;
and I wrote persistence-unit name in persistence.xml file
<persistence-unit name="Sharif" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
and I also use Entity annotation in my entity class (Person)
I check almost all Question that relates to my problem but I can't solve it.
project dependencies:
I created a new project and copy all my code in it. I guess my problem happened because of existing 2 version of hibernate-core.jar
, this file hibernate-core-5.2.10.Final.jar
and this hibernate-core-5.2.1.Final.jar
. I deleted extra jar files and copied new lib folder into the new project and it runs successfully.