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

Grails 5.2 app with Micronaut beans will not run with embedded Tomcat #12625

Closed
JasonTypesCodes opened this issue Jul 18, 2022 · 2 comments · Fixed by micronaut-projects/micronaut-core#7705
Assignees
Milestone

Comments

@JasonTypesCodes
Copy link
Member

Expected Behavior

The application should start

Actual Behaviour

The application fails with:

java.nio.file.ProviderNotFoundException: null
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:603)
        at java.base/java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:678)
        at java.base/java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:722)
        at io.micronaut.core.io.service.SoftServiceLoader$DefaultServiceCollector.collect(SoftServiceLoader.java:536)
        at io.micronaut.core.io.service.SoftServiceLoader.collectDynamicServices(SoftServiceLoader.java:199)
        at io.micronaut.core.io.service.SoftServiceLoader.collectAll(SoftServiceLoader.java:175)
        at io.micronaut.context.DefaultBeanContext.resolveBeanDefinitionReferences(DefaultBeanContext.java:1732)
        at io.micronaut.context.DefaultApplicationContext.isBootstrapPropertySourceLocatorPresent(DefaultApplicationContext.java:153)
        at io.micronaut.context.DefaultApplicationContext.isBootstrapEnabled(DefaultApplicationContext.java:149)
        at io.micronaut.context.DefaultApplicationContext.createEnvironment(DefaultApplicationContext.java:137)
        at io.micronaut.context.DefaultApplicationContext.getEnvironment(DefaultApplicationContext.java:181)
        at grails.boot.GrailsApp.createApplicationContext(GrailsApp.groovy:181)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:99)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:485)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:472)
        at gr52.mn.bug.Application.main(Application.groovy:11)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
        at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59)
Caused by: java.nio.file.ProviderNotFoundException: Provider not found
        at java.base/java.nio.file.FileSystems.newFileSystem(FileSystems.java:423)
        at io.micronaut.core.io.IOUtils.loadNestedJarUri(IOUtils.java:153)
        at io.micronaut.core.io.IOUtils.eachFile(IOUtils.java:99)
        at io.micronaut.core.io.service.SoftServiceLoader.computeServiceTypeNames(SoftServiceLoader.java:277)
        at io.micronaut.core.io.service.SoftServiceLoader.access$1100(SoftServiceLoader.java:68)
        at io.micronaut.core.io.service.SoftServiceLoader$MicronautMetaServicesLoader.compute(SoftServiceLoader.java:565)
        at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:189)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

Steps To Reproduce

  1. Create new Grails 5.2.1 application
  2. ./gradlew bootWar
  3. java -jar build/libs/gr52-mn-bug-0.1.war
  4. Application Starts
  5. Add a Micronaut bean
  6. ./gradlew clean bootWar
  7. java -jar build/libs/gr52-mn-bug-0.1.war
  8. Observe the exception above

Environment Information

  • Debian 11
  • Grails 5.2.1
  • openjdk version "11.0.12" 2021-07-20

Example Application

https://github.com/JasonTypesCodes/gr52-mn-bug

Version

5.2.1

@puneetbehl puneetbehl self-assigned this Jul 18, 2022
@puneetbehl puneetbehl added this to the 5.2.2 milestone Jul 18, 2022
yawkat added a commit to micronaut-projects/micronaut-core that referenced this issue Jul 19, 2022
Spring boot's LaunchedURLClassLoader creates weird urls that have directories that look like jars. This patch makes IOUtils handle such URLs.
Fixes grails/grails-core#12625
@puneetbehl
Copy link
Contributor

puneetbehl commented Jul 19, 2022

I worked with @yawkat today and it seems the problem is with Spring Boot LaunchedUrlClassLoader where it tried to load resource as following:
jar:file:/private/tmp/testmn/build/libs/testmn-0.1.jar!/BOOT-INF/classes!/META-INF/micronaut/io.micronaut.inject.BeanDefinitionReference

Please note the extra ! after classes which seems weird but I am not sure whether it is intentional or NOT, we are handling this special case in the Micronaut IOUtils class.

yawkat added a commit to micronaut-projects/micronaut-core that referenced this issue Jul 20, 2022
Spring boot's LaunchedURLClassLoader creates weird urls that have directories that look like jars. This patch makes IOUtils handle such URLs.
Fixes grails/grails-core#12625
@JasonTypesCodes
Copy link
Member Author

Confirmed the fix in 5.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants