Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » class not found issues migrating to 3.0.2(java.lang.NoClassDefFoundError: jakarta/persistence/spi/PersistenceProvider when creating the jpa provider)
class not found issues migrating to 3.0.2 [message #1848434] Thu, 02 December 2021 01:48 Go to next message
Phil Scadden is currently offline Phil ScaddenFriend
Messages: 12
Registered: July 2010
Junior Member
Move to JDK11 also results in going to eclipselink 3.
App is tomcat 9, Spring-JPA (not spring boot).

        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>eclipselink</artifactId>
            <version>3.0.2</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>jakarta.persistence</groupId>
            <artifactId>jakarta.persistence-api</artifactId>
            <version>2.2.3</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>jakarta.annotation</groupId>
            <artifactId>jakarta.annotation-api</artifactId>
            <version>2.0.0</version>
            <type>jar</type>
        </dependency>

in the setup, I have:
    @Bean
    @Primary
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
        LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
        emfb.setDataSource(dataSource());
        emfb.setPersistenceUnitName("MyAPPJPA");
        emfb.setPackagesToScan("myApp.domain");
        JpaVendorAdapter jva  = createJpaVendorAdapter();
        emfb.setJpaVendorAdapter(jva);
        emfb.setJpaPropertyMap(getVendorProperties());
        return emfb;
    }

    protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
        EclipseLinkJpaVendorAdapter eclipseLinkJpaVendorAdapter  = new EclipseLinkJpaVendorAdapter();
        eclipseLinkJpaVendorAdapter.setShowSql(true);
        eclipseLinkJpaVendorAdapter.setGenerateDdl(false);
        return eclipseLinkJpaVendorAdapter;
    }


It dies at new EclipseLinkJpaVendorAdaptor()
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: Factory method 'entityManagerFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: jakarta/persistence/spi/PersistenceProvider
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
... 59 more
Caused by: java.lang.NoClassDefFoundError: jakarta/persistence/spi/PersistenceProvider

But if I look at the dependencies, I see jakarta/persistence/spi/PersistenceProvider
right there in the jakarta.persistance-api.jar

Dont have issue if I use hibernate latest instead, but that involves going places that Eclipselink does best.

Re: class not found issues migrating to 3.0.2 [message #1848436 is a reply to message #1848434] Thu, 02 December 2021 07:16 Go to previous message
Radek Felcman is currently offline Radek FelcmanFriend
Messages: 22
Registered: March 2021
Junior Member
Please use
jakarta.persistence:jakarta.persistence-api:3.0.0
as a dependency. 3.x version keeps JPA classes in jakarta.* package.
Mentioned JPA version 2.2.3 (2.x) using javax.* package.
3.x persistence-api + 3.x EclipseLink = jakarta.* package
2.x persistence-api + 2.x EclipseLink = javax.* package
Previous Topic:EclipseLink 2.7.x OneToMany relation and composite id
Next Topic:P2 Repository for Eclipselink 3.0.2
Goto Forum:
  


Current Time: Tue Dec 10 19:17:17 GMT 2024

Powered by FUDForum. Page generated in 0.04540 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top