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

After upgrading Micronaut Gradle plugin from 3.2.2 to 3.3.0 fat-JAR application launch crashes with No bean of type [io.micronaut.context.event.ApplicationEventPublisher<io.micronaut.context.event.StartupEvent>] exists #406

Closed
drmoeller opened this issue Mar 22, 2022 · 4 comments · Fixed by #407 or #412
Assignees
Labels
type: bug Something isn't working

Comments

@drmoeller
Copy link

Expected Behavior

Application should launch smoothly like before the upgrade.

Actual Behaviour

Application's Single-JAR is currently built using following plugin:
id('com.github.johnrengelman.shadow') version '7.+'

After upgrading Gradle Micronaut plugin from
id('io.micronaut.application') version '3.2.2'
to
id('io.micronaut.application') version '3.3.0'
launching the Single-JAR application like so
java -jar build/libs/application-0.1-all.jar
breaks with

10:16:17.436Z [   main] ERROR - Error starting Micronaut server: No bean of type [io.micronaut.context.event.ApplicationEventPublisher<io.micronaut.context.event.StartupEvent>] exists. Make sure the bean is not disabled by bean requirements (enable trace logging for 'io.micronaut.context.condition' to check) and if the bean is enabled then ensure the class is declared a bean and annotation processing is enabled (for Java and Kotlin the 'micronaut-inject-java' dependency should be configured as an annotation processor).
io.micronaut.context.exceptions.NoSuchBeanException: No bean of type [io.micronaut.context.event.ApplicationEventPublisher<io.micronaut.context.event.StartupEvent>] exists. Make sure the bean is not disabled by bean requirements (enable trace logging for 'io.micronaut.context.condition' to check) and if the bean is enabled then ensure the class is declared a bean and annotation processing is enabled (for Java and Kotlin the 'micronaut-inject-java' dependency should be configured as an annotation processor).
	at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:2795)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1654)
	at io.micronaut.context.BeanLocator.getBean(BeanLocator.java:94)
	at io.micronaut.context.DefaultBeanContext.publishEvent(DefaultBeanContext.java:1733)
	at io.micronaut.context.DefaultBeanContext.start(DefaultBeanContext.java:344)
	at io.micronaut.context.DefaultApplicationContext.start(DefaultApplicationContext.java:183)
	at io.micronaut.runtime.Micronaut.start(Micronaut.java:72)
	[...]

reproducibly.

With enabled trace logging (as requested) the following message appears just in front of the one cited above:

DEBUG - Bean [foo.bar.baz.$OrderStatePublisherHttpClientImpl$Definition$Intercepted$Definition] will not be loaded due to failing conditions:

Also explicit addition of mentioned library with Kotlin APT via kapt('io.micronaut:micronaut-inject-java') doesn't help.

None of the application's types explicitly implement mentioned interface io.micronaut.context.event.ApplicationEventPublisher<io.micronaut.context.event.StartupEvent>.

After switching back to id('io.micronaut.application') version '3.2.2' app launches smoothly (with lots of messages regarding bean conditionals due to enabled trace logging of this feature).

Steps To Reproduce

See above.

$ ./gradlew clean assemble && java -jar build/libs/application-0.1-all.jar

Environment Information

  • JRE 17.0.2
  • Kotlin 1.6.10
  • Gradle 7.4.1
  • Micronaut 3.3.4

Example Application

No response

Version

3.3.4

@melix
Copy link
Collaborator

melix commented Mar 22, 2022

Bug is not specific to Kotlin, also happens with Java.

@melix melix self-assigned this Mar 22, 2022
@melix melix added the type: bug Something isn't working label Mar 22, 2022
@melix
Copy link
Collaborator

melix commented Mar 22, 2022

Workaround is to add:

tasks.withType(ShadowJar.class).configureEach(ShadowJar::mergeServiceFiles)

to your build script

melix added a commit that referenced this issue Mar 22, 2022
This commit fixes shadow jar building, by making sure that the generated
jar merges service files.

Fixes #406
melix added a commit that referenced this issue Mar 22, 2022
* Fix service files not merged with shadow plugin

This commit fixes shadow jar building, by making sure that the generated
jar merges service files.

Fixes #406

* Upgrade shadow plugin
@drmoeller
Copy link
Author

Thanks for immediate reaction, including workaround.

tobiasschaefer added a commit to tobiasschaefer/micronaut-camunda-external-client that referenced this issue Mar 23, 2022
tobiasschaefer added a commit to camunda-community-hub/micronaut-zeebe-client that referenced this issue Mar 23, 2022
tobiasschaefer added a commit to tobiasschaefer/micronaut-camunda-external-client that referenced this issue Mar 23, 2022
tobiasschaefer added a commit to camunda-community-hub/micronaut-camunda-external-client that referenced this issue Mar 23, 2022
tobiasschaefer added a commit to camunda-community-hub/micronaut-camunda-platform-7 that referenced this issue Mar 23, 2022
@sdelamo sdelamo reopened this Mar 25, 2022
@sdelamo
Copy link
Contributor

sdelamo commented Mar 25, 2022

It stills fails for Application Type: Serverless Function and Micronaut Gradle Plugin library.

#407 applies to MicronautMinimalApplicationPlugin but not MicronautMinimalLibraryPlugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
3 participants