Open donbeave opened 5 months ago
You might want to check if it did create a shadow jar and if meta-inf services are merged correctly
You might want to check if it did create a shadow jar and if meta-inf services are merged correctly
There is only one file in services:
java.nio.file.spi.FileSystemProvider
There is no shadow jar, as it normal Spring Boot application created with Spring Initializer (https://start.spring.io) with micronaut-spring-boot
dependency. It's not using Micronaut Gradle plugin and Gradle Shadow plugin. It's using Micronaut as parent context for Spring Boot application.
@dstepanov I found a related issue in Micronaut Gradle plugin: https://github.com/micronaut-projects/micronaut-gradle-plugin/issues/406, the only difference is that in my case I'm using Micronaut as a parent context without Gradle shadow and Micronaut Gradle plugins, only Spring gradle plugin with micronaut-spring-boot
dependency. It worked fine for Micronaut 3, but not for Micronaut 4. Has something changed in 4th version and need to add some extra config?
Looks like there was some change in Spring Boot 3. Config below helps to resolve this issue:
tasks.bootJar { loaderImplementation = org.springframework.boot.loader.tools.LoaderImplementation.CLASSIC }
The upstream change in Spring Boot 3.2 is documented in the release notes.
The previous URL format of jar:file:/dir/myjar.jar:BOOT-INF/lib/nested.jar!/com/example/MyClass.class has been replaced with jar:nested:/dir/myjar.jar/!BOOT-INF/lib/nested.jar!/com/example/MyClass.class.
A new NestedFileSystemProvider was added in support of this new scheme.
However, micronaut-spring has code that prepends any jarUri that isn't starting with "file:" with that scheme:
https://github.com/micronaut-projects/micronaut-core/blob/0118db96962eaf7a83abbcb81c1afd73139ff777/core/src/main/java/io/micronaut/core/io/IOUtils.java#L156-L162
So you get something like file:/nested:/dir/myjar.jar/!BOOT-INF/lib/nested.jar!/com/example/MyClass.class
That causes the FileSystemProvider
for "file:" to be used instead of Spring's NestedFileSystemProvider
, and that former one won't be able to load /nested:.../
.
This is then causing the ServiceScanner to be unable to find any META-INF/micronaut/io.micronaut.inject.BeanDefinitionReference
files listing out bean definitions, causing those NoSuchBeanException
.
Expected Behavior
No response
Actual Behaviour
gradle bootRun
works well, but building the application as jar file and running it leads to an startup error:Steps To Reproduce
micronaut-spring-no-bean-of-type-applicationeventpublisher-exists
repositoryEnvironment Information
JDK Version:
Example Application
https://github.com/donbeave/micronaut-spring-no-bean-of-type-applicationeventpublisher-exists
Version
4.2.3