0
votes

I'm trying to start a javafx application that uses eclipselink and a local H2 database, but I'm getting the following error:

 Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.salesinvoicetools.salesinvoicetools/com.salesinvoicetools.AppWindow.subMain(AppWindow.java:62)
    at com.salesinvoicetools.salesinvoicetools/com.salesinvoicetools.Starter.main(Starter.java:13)
Caused by: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.7.8.v20201217-ecdf3c32c4): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: jdk.internal.loader.ClassLoaders$AppClassLoader@233c0b17
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.7.8.v20201217-ecdf3c32c4): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [h2-localdb] failed.
Internal Exception: java.lang.IncompatibleClassChangeError: class org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAsmFactory$ClassMetadataVisitor can not implement org.eclipse.persistence.internal.libraries.asm.ClassVisitor, because it is not an interface (org.eclipse.persistence.internal.l
    at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:129)
    at [email protected]/org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:107)
    at [email protected]/org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
    at [email protected]/javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
    at [email protected]/javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
    at com.salesinvoicetools.salesinvoicetools/com.salesinvoicetools.dataaccess.DataAccessBase.setEntityManager(DataAccessBase.java:23)
    at com.salesinvoicetools.salesinvoicetools/com.salesinvoicetools.dataaccess.DataAccessBase.<clinit>(DataAccessBase.java:19)
    ... 2 more
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.7.8.v20201217-ecdf3c32c4): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [h2-localdb] failed.
Internal Exception: java.lang.IncompatibleClassChangeError: class org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAsmFactory$ClassMetadataVisitor can not implement org.eclipse.persistence.internal.libraries.asm.ClassVisitor, because it is not an interface (org.eclipse.persistence.internal.l
    at [email protected]/org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:1950)
    at [email protected]/org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1941)
    at [email protected]/org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:98)
    at [email protected]/org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:96)
    ... 7 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.7.8.v20201217-ecdf3c32c4): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [h2-localdb] failed.
Internal Exception: java.lang.IncompatibleClassChangeError: class org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAsmFactory$ClassMetadataVisitor can not implement org.eclipse.persistence.internal.libraries.asm.ClassVisitor, because it is not an interface (org.eclipse.persistence.internal.l
    at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:233)
    ... 11 more
Caused by: java.lang.IncompatibleClassChangeError: class org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAsmFactory$ClassMetadataVisitor can not implement org.eclipse.persistence.internal.libraries.asm.ClassVisitor, because it is not an interface (org.eclipse.persistence.internal.l
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1010)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1088)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:182)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:814)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassInModuleOrNull(BuiltinClassLoader.java:735)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:660)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:634)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
    at [email protected]/org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processEntityMappings(MetadataProcessor.java:538)
    at [email protected]/org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:581)
    at [email protected]/org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1865)
    ... 9 more

I copied the persistence code from an older eclipse project that uses h2 and eclipselink too, but now it doesn't start. I tried adding several requires statements to the module-info.java but still no change.

Here are the entries in the pom.xml file:

<dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>eclipselink</artifactId>
        <version>2.7.8</version>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.4.200</version>
    </dependency>

Any ideas?

1

1 Answers

0
votes

Possible you have two version of eclipselink in your dependencies.

Old version 2.5.0 have an interface ClassVisitor

package org.eclipse.persistence.internal.libraries.asm;

/**
 * A visitor to visit a Java class. The methods of this interface must be called
 * in the following order: <tt>visit</tt> [ <tt>visitSource</tt> ] [
 * <tt>visitOuterClass</tt> ] ( <tt>visitAnnotation</tt> |
 * <tt>visitAttribute</tt> )* (<tt>visitInnerClass</tt> |
 * <tt>visitField</tt> | <tt>visitMethod</tt> )* <tt>visitEnd</tt>.
 * 
 * @author Eric Bruneton
 */
public interface ClassVisitor {...

new version 2.7.8 have an abstract class ClassVisitor:

package org.eclipse.persistence.internal.libraries.asm;

/**
 * A visitor to visit a Java class. The methods of this class must be called in the following order:
 * {@code visit} [ {@code visitSource} ] [ {@code visitModule} ][ {@code visitNestHost} ][ {@code
 * visitPermittedSubclass} ][ {@code visitOuterClass} ] ( {@code visitAnnotation} | {@code
 * visitTypeAnnotation} | {@code visitAttribute} )* ( {@code visitNestMember} | {@code
 * visitInnerClass} | {@code visitRecordComponent} | {@code visitField} | {@code visitMethod} )*
 * {@code visitEnd}.
 *
 * @author Eric Bruneton
 */
public abstract class ClassVisitor {

You have to remove one of two dependencies