Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

META-INF entries are duplicated under BOOT-INF/classes causing "Conflicting persistence unit definitions" error #38862

Closed
rmatec opened this issue Dec 19, 2023 · 5 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@rmatec
Copy link

rmatec commented Dec 19, 2023

Hi,

We recently upgraded to Spring Boot 3.2.0 and we are seeing the following error when the service starts up.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/config/EclipseLinkJpaConfiguration.class]: Conflicting persistence unit definitions for name 'persistence-config': nested:/opt/application/service.jar/!BOOT-INF/classes/, file:/opt/application/service.jar

We have the persistence configuration in src/main/resources/META-INF/persistence.xml

Am I right to think this is because of the new Nested Jar Support? It appears the jar file is twice in the error message above, one with nested:... and one without.

If we fallback to the classic loader the service starts up ok.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 19, 2023
@scottfrederick
Copy link
Contributor

@rmatec We have fixed several issues in the area of the new loader. Can you test with the latest Spring Boot 3.2.1-SNAPSHOT and see if your use case works without falling back to the classic loader?

@scottfrederick scottfrederick added the status: waiting-for-feedback We need additional information before we can continue label Dec 19, 2023
@rmatec
Copy link
Author

rmatec commented Dec 19, 2023

@scottfrederick I tried with the snapshot version but I am getting the same error.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 19, 2023
@philwebb
Copy link
Member

@rmatec Can you please provide the full stacktrace and if possible a sample application that reproduces the problem.

@philwebb philwebb added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Dec 19, 2023
@rmatec
Copy link
Author

rmatec commented Dec 20, 2023

Hi @philwebb
I created the following repo with a simple example https://github.com/rmatec/nested-jars-issue
To reproduce the issue, generate a jar file and run it.

2023-12-20T17:29:22.332Z ERROR 148390 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Conflicting persistence unit definitions for name 'persistence-config': nested:/home/rmatec/git/nested-jars-issue/build/libs/demo-0.0.1-SNAPSHOT.jar/!BOOT-INF/classes/, file:/home/rmatec/git/nested-jars-issue/build/libs/demo-0.0.1-SNAPSHOT.jar
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1775) ~[spring-beans-6.1.1.jar!/:6.1.1]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601) ~[spring-beans-6.1.1.jar!/:6.1.1]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523) ~[spring-beans-6.1.1.jar!/:6.1.1]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:325) ~[spring-beans-6.1.1.jar!/:6.1.1]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.1.1.jar!/:6.1.1]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:323) ~[spring-beans-6.1.1.jar!/:6.1.1]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-6.1.1.jar!/:6.1.1]
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1173) ~[spring-context-6.1.1.jar!/:6.1.1]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:936) ~[spring-context-6.1.1.jar!/:6.1.1]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:616) ~[spring-context-6.1.1.jar!/:6.1.1]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:753) ~[spring-boot-3.2.0.jar!/:3.2.0]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:455) ~[spring-boot-3.2.0.jar!/:3.2.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:323) ~[spring-boot-3.2.0.jar!/:3.2.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1342) ~[spring-boot-3.2.0.jar!/:3.2.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1331) ~[spring-boot-3.2.0.jar!/:3.2.0]
	at com.example.demo.DemoApplication.main(DemoApplication.java:10) ~[!/:0.0.1-SNAPSHOT]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
	at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:91) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
	at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:53) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
	at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:58) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: java.lang.IllegalStateException: Conflicting persistence unit definitions for name 'persistence-config': nested:/home/rmatec/git/nested-jars-issue/build/libs/demo-0.0.1-SNAPSHOT.jar/!BOOT-INF/classes/, file:/home/rmatec/git/nested-jars-issue/build/libs/demo-0.0.1-SNAPSHOT.jar
	at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:495) ~[spring-orm-6.1.1.jar!/:6.1.1]
	at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.afterPropertiesSet(DefaultPersistenceUnitManager.java:435) ~[spring-orm-6.1.1.jar!/:6.1.1]
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:339) ~[spring-orm-6.1.1.jar!/:6.1.1]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1822) ~[spring-beans-6.1.1.jar!/:6.1.1]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1771) ~[spring-beans-6.1.1.jar!/:6.1.1]
	... 22 common frames omitted

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 20, 2023
@philwebb philwebb added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Dec 20, 2023
@philwebb philwebb added this to the 3.2.x milestone Dec 20, 2023
@philwebb philwebb self-assigned this Dec 20, 2023
@philwebb philwebb changed the title Nested Jar Support and persistence configuration META-INF entries are duplicated under BOOT-INF/classes causing "Conflicting persistence unit definitions" error Dec 21, 2023
@philwebb philwebb modified the milestones: 3.2.x, 3.2.1 Dec 21, 2023
@rmatec
Copy link
Author

rmatec commented Dec 21, 2023

Thanks @philwebb

ndwnu pushed a commit to ndwnu/nls-routing-map-matcher that referenced this issue Apr 10, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [org.apache.maven.plugins:maven-surefire-plugin](https://maven.apache.org/surefire/) | build | patch | `3.2.2` -> `3.2.5` |
| [org.apache.maven.plugins:maven-failsafe-plugin](https://maven.apache.org/surefire/) | build | patch | `3.2.2` -> `3.2.5` |
| [org.springframework.boot:spring-boot-starter-parent](https://spring.io/projects/spring-boot) ([source](https://github.com/spring-projects/spring-boot)) | parent | patch | `3.2.0` -> `3.2.1` |

---

### Release Notes

<details>
<summary>spring-projects/spring-boot (org.springframework.boot:spring-boot-starter-parent)</summary>

### [`v3.2.1`](https://github.com/spring-projects/spring-boot/releases/tag/v3.2.1)

[Compare Source](spring-projects/spring-boot@v3.2.0...v3.2.1)

#### 🐞 Bug Fixes

-   HibernateJpaAutoConfiguration should be applied before DataSourceTransactionManagerAutoConfiguration [#&#8203;38880](spring-projects/spring-boot#38880)
-   META-INF entries are duplicated under BOOT-INF/classes causing "Conflicting persistence unit definitions" error [#&#8203;38862](spring-projects/spring-boot#38862)
-   logging.include-application-name has no effect when using log4j2 [#&#8203;38847](spring-projects/spring-boot#38847)
-   Pulsar authentication param properties cause IllegalStateException with Pulsar Client 3.1.0  [#&#8203;38839](spring-projects/spring-boot#38839)
-   Child context created with SpringApplicationBuilder runs parents runners [#&#8203;38837](spring-projects/spring-boot#38837)
-   getSigners() info is lost for signed jars when using the new loader implementation with requiresUnpack [#&#8203;38833](spring-projects/spring-boot#38833)
-   TestContainers parallel initialization doesn't work properly  [#&#8203;38831](spring-projects/spring-boot#38831)
-   Zip file closed exceptions can be thrown due to StaticResourceJars closing jars from cached connections [#&#8203;38770](spring-projects/spring-boot#38770)
-   Multi-byte filenames in zip files can cause an endless loop in ZipString.hash [#&#8203;38751](spring-projects/spring-boot#38751)
-   Gradle task "bootJar" fails with "Failed to get permissions" when using Gradle 8.6-milestone-1 [#&#8203;38741](spring-projects/spring-boot#38741)
-   Custom binding converters are ignored when working with collection types [#&#8203;38734](spring-projects/spring-boot#38734)
-   WebFlux and resource server auto-configuration may fail due to null authentication manager [#&#8203;38713](spring-projects/spring-boot#38713)
-   It is unclear that Docker Compose services have not been started as one or more is already run...
ndwlocatieservices added a commit to ndwnu/nls-routing-map-matcher that referenced this issue Apr 16, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [org.apache.maven.plugins:maven-surefire-plugin](https://maven.apache.org/surefire/) | build | patch | `3.2.2` -> `3.2.5` |
| [org.apache.maven.plugins:maven-failsafe-plugin](https://maven.apache.org/surefire/) | build | patch | `3.2.2` -> `3.2.5` |
| [org.springframework.boot:spring-boot-starter-parent](https://spring.io/projects/spring-boot) ([source](https://github.com/spring-projects/spring-boot)) | parent | patch | `3.2.0` -> `3.2.1` |

---

### Release Notes

<details>
<summary>spring-projects/spring-boot (org.springframework.boot:spring-boot-starter-parent)</summary>

### [`v3.2.1`](https://github.com/spring-projects/spring-boot/releases/tag/v3.2.1)

[Compare Source](spring-projects/spring-boot@v3.2.0...v3.2.1)

#### 🐞 Bug Fixes

-   HibernateJpaAutoConfiguration should be applied before DataSourceTransactionManagerAutoConfiguration [#&#8203;38880](spring-projects/spring-boot#38880)
-   META-INF entries are duplicated under BOOT-INF/classes causing "Conflicting persistence unit definitions" error [#&#8203;38862](spring-projects/spring-boot#38862)
-   logging.include-application-name has no effect when using log4j2 [#&#8203;38847](spring-projects/spring-boot#38847)
-   Pulsar authentication param properties cause IllegalStateException with Pulsar Client 3.1.0  [#&#8203;38839](spring-projects/spring-boot#38839)
-   Child context created with SpringApplicationBuilder runs parents runners [#&#8203;38837](spring-projects/spring-boot#38837)
-   getSigners() info is lost for signed jars when using the new loader implementation with requiresUnpack [#&#8203;38833](spring-projects/spring-boot#38833)
-   TestContainers parallel initialization doesn't work properly  [#&#8203;38831](spring-projects/spring-boot#38831)
-   Zip file closed exceptions can be thrown due to StaticResourceJars closing jars from cached connections [#&#8203;38770](spring-projects/spring-boot#38770)
-   Multi-byte filenames in zip files can cause an endless loop in ZipString.hash [#&#8203;38751](spring-projects/spring-boot#38751)
-   Gradle task "bootJar" fails with "Failed to get permissions" when using Gradle 8.6-milestone-1 [#&#8203;38741](spring-projects/spring-boot#38741)
-   Custom binding converters are ignored when working with collection types [#&#8203;38734](spring-projects/spring-boot#38734)
-   WebFlux and resource server auto-configuration may fail due to null authentication manager [#&#8203;38713](spring-projects/spring-boot#38713)
-   It is unclear that Docker Compose services have not been started as one or more is already run...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

4 participants