javax.стойкость.PersistenceException с помощью createEntityManagerFactory

Мой следующий код работает на моем Windows, но не работает на моем Linux Mint. A добавлены все соответствующие библиотеки.
Я получаю это исключение для строки createEntityManagerFactory:

javax.persistence.PersistenceException: Explicit persistence provider error(s) occurred for "JPA_probaPU" after trying the following discovered implementations: org.eclipse.persistence.jpa.PersistenceProvider from provider: org.eclipse.persistence.jpa.PersistenceProvider

Мой файл java:

package jpa_proba;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.eclipse.persistence.exceptions.EntityManagerSetupException;

public class JPA_proba {

public static void main(String[] args) {
    try{
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("JPA_probaPU");
    EntityManager em = emf.createEntityManager();
    em.getTransaction().begin();
    //Integer id, String isbn, String szerzo, String cim, String mufaj, int ar, int elerheto
    Konyv k = new  Konyv(null, "654654444444", "Kiss Béla", "Hogyan ne csináljunk semmit?", "dráma", 500, 1);
    em.persist(k);
    em.getTransaction().commit();
    }
    catch(Exception ex){
    System.out.println(ex);
    }
  }

}

Мое упорство.XML:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"   xsi_schemaLocation="http:// transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>jpa_proba.Konyv</class>
    <properties>
      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/helix1?zeroDateTimeBehavior=convertToNull"/>
      <property name="javax.persistence.jdbc.user" value="root"/>
      <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
      <property name="javax.persistence.jdbc.password" value="123456"/>
    </properties>
  </persistence-unit>
</persistence>

Ошибки:

Exception in thread "main" javax.persistence.PersistenceException: Explicit persistence provider error(s) occurred for "JPA_probaPU" after trying the following discovered implementations: org.eclipse.persistence.jpa.PersistenceProvider from provider: org.eclipse.persistence.jpa.PersistenceProvider
at javax.persistence.Persistence.createPersistenceException(Persistence.java:244)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:186)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:72)
at jpa_proba.JPA_proba.main(JPA_proba.java:13)
Caused by: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5):     org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoad er@5caf905d
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [JPA_probaPU] failed.
Internal Exception: java.lang.IncompatibleClassChangeError: Implementing class
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:107)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:152)

1 ответ

  1. Вы получаете Internal Exception: java.lang.IncompatibleClassChangeError: Implementing class.

    Это может произойти при наличии нескольких версий одного класса/jar.