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

BUG 3.4.0: No bean of type io.micronaut.context.event.ApplicationEventPublisher exists #7144

Closed
codeconsole opened this issue Mar 25, 2022 · 10 comments
Labels
closed: duplicate This issue or pull request already exists info: workaround available A workaround is available for the issue

Comments

@codeconsole
Copy link

codeconsole commented Mar 25, 2022

This is a bug new to v3.4.0 - Perhaps test building a basic empty app before future releases?

v3.3.4 works fine

Expected Behavior

Freshly created basic app can be run via java -jar./build/libs/test-0.1-all.jar

./gradlew run works:
20:06:55.564 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 285ms. Server Running: http://localhost:8080

java -jar ./build/libs/test-0.1-all.jar does not work

Actual Behaviour

% ./gradlew assemble
% java -jar ./build/libs/test-0.1-all.jar
 __  __ _                                  _   
|  \/  (_) ___ _ __ ___  _ __   __ _ _   _| |_ 
| |\/| | |/ __| '__/ _ \| '_ \ / _` | | | | __|
| |  | | | (__| | | (_) | | | | (_| | |_| | |_ 
|_|  |_|_|\___|_|  \___/|_| |_|\__,_|\__,_|\__|
  Micronaut (v3.4.0)

20:02:41.144 [main] ERROR io.micronaut.runtime.Micronaut - 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)
	at io.micronaut.runtime.Micronaut.run(Micronaut.java:320)
	at io.micronaut.runtime.Micronaut.run(Micronaut.java:306)
	at test.Application.main(Application.java:8)

Steps To Reproduce

% sdk use java 11.0.14-zulu  
% sdk use micronaut 3.4.0
% mn create-app test
% cd test
% ./gradlew assemble
% java -jar ./build/libs/test-0.1-all.jar

Environment Information

macOS Monterey 12.3
MacBook Pro (14-Inch, 2021)
Chip Apple M1 Pro
Memory 16 GB

Example Application

No response

Version

3.4.0

@codeconsole codeconsole changed the title java -jar: Error starting Micronaut server: No bean of type [io.micronaut.context.event.ApplicationEventPublisher<io.micronaut.context.event.StartupEvent>] exists BUG 3.4.0: No bean of type io.micronaut.context.event.ApplicationEventPublisher exists Mar 25, 2022
@graemerocher
Copy link
Contributor

@sdelamo sdelamo added the closed: duplicate This issue or pull request already exists label Mar 25, 2022
@sdelamo
Copy link
Contributor

sdelamo commented Mar 25, 2022

Workaround:


shadowJar {
    mergeServiceFiles()
}

@sdelamo sdelamo closed this as completed Mar 25, 2022
@sdelamo sdelamo added the info: workaround available A workaround is available for the issue label Mar 25, 2022
@codeconsole
Copy link
Author

Thanks for the fast response and providing a workaround that I can confirm works.

@sivaprasadreddy
Copy link

sivaprasadreddy commented Nov 17, 2024

I am using Micronaut 4.7.0 with Maven and I am getting the same Exception only on GitHub Actions, but running fine locally.

[test-resources-service] 11:45:41.353 [pool-1-thread-1] INFO  tc.testcontainers/ryuk:0.9.0 - Container testcontainers/ryuk:0.9.0 started in PT0.55039206S
[test-resources-service] 11:45:41.358 [pool-1-thread-1] INFO  o.t.utility.RyukResourceReaper - Ryuk started - will monitor and terminate Testcontainers containers on JVM exit
[test-resources-service] 11:45:41.358 [pool-1-thread-1] INFO  o.testcontainers.DockerClientFactory - Checking the system...
[test-resources-service] 11:45:41.358 [pool-1-thread-1] INFO  o.testcontainers.DockerClientFactory - ✔︎ Docker server version should be at least 1.6.0
Error: Exception in thread "main" io.micronaut.runtime.exceptions.ApplicationStartupException: Error starting Micronaut server: No bean of type [io.micronaut.context.event.ApplicationEventPublisher<io.micronaut.context.event.StartupEvent>] exists. 
	at io.micronaut.runtime.Micronaut.handleStartupException(Micronaut.java:353)
	at io.micronaut.runtime.Micronaut.start(Micronaut.java:1[74](https://github.com/sivaprasadreddy/joyful-devex-using-testcontainers/actions/runs/11878556800/job/33099369073#step:4:75))
	at io.micronaut.runtime.Micronaut.run(Micronaut.java:334)
	at io.micronaut.runtime.Micronaut.run(Micronaut.java:320)
	at io.micronaut.testresources.server.TestResourcesService.main(TestResourcesService.java:43)
Caused by: io.micronaut.context.exceptions.NoSuchBeanException: No bean of type [io.micronaut.context.event.ApplicationEventPublisher<io.micronaut.context.event.StartupEvent>] exists. 
	at io.micronaut.context.DefaultBeanContext.newNoSuchBeanException(DefaultBeanContext.java:2798)
	at io.micronaut.context.DefaultApplicationContext.newNoSuchBeanException(DefaultApplicationContext.java:329)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2761)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1745)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:842)
	at io.micronaut.context.BeanLocator.getBean(BeanLocator.java:97)
	at io.micronaut.context.DefaultBeanContext.publishEvent(DefaultBeanContext.java:1831)
	at io.micronaut.context.DefaultBeanContext.start(DefaultBeanContext.java:360)
	at io.micronaut.context.DefaultApplicationContext.start(DefaultApplicationContext.java:216)
	at io.micronaut.runtime.Micronaut.start(Micronaut.java:[75](https://github.com/sivaprasadreddy/joyful-devex-using-testcontainers/actions/runs/11878556800/job/33099369073#step:4:76))
	... 3 more

@dirkhas
Copy link

dirkhas commented Dec 6, 2024

I'm seeing this error in github actions too, after upgrading to 4.7.1. Simply using 4.6.3 instead makes the error go away.

@graemerocher
Copy link
Contributor

@dirkhas @sivaprasadreddy do you have reproducers?

@melix
Copy link
Contributor

melix commented Dec 6, 2024

seems to be related to micronaut-projects/micronaut-test-resources#785

@dirkhas
Copy link

dirkhas commented Dec 6, 2024

@dirkhas @sivaprasadreddy do you have reproducers?

@graemerocher I'm afraid not. I'm seeing the problem in a work project I can't share.

seems to be related to micronaut-projects/micronaut-test-resources#785

@melix Super interesting, my project uses test resources too 👀

@sivaprasadreddy
Copy link

@graemerocher
Now it got more interesting. The PR to update to 4.7.1 failed: https://github.com/sivaprasadreddy/joyful-devex-using-testcontainers/actions/runs/11992348693/job/33432062373

Somehow after upgrading to version 4.7.1, the build succeed in GitHub Actions pipeline https://github.com/sivaprasadreddy/joyful-devex-using-testcontainers/actions/runs/12213382342/job/34072929948

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed: duplicate This issue or pull request already exists info: workaround available A workaround is available for the issue
Projects
None yet
Development

No branches or pull requests

6 participants