apache / apache/grails-core

Camel Context not injected when service implements ApplicationEventListener

Open
#11,597 1 comment 0 reactions 1 assignee Claimed by @puneetbehl View on GitHub
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

We would like to leverage a Spring Camel context in our grails services. We can do this just fine in a regular Grails service. However, as soon as a Grails service implements the Micronaut ApplicationEventListener, the server application fails to start up with the following error:

```
Caused by: io.micronaut.context.exceptions.NoSuchBeanException: No bean of type [com.xyz.SomeService] 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).
```
As soon as I remove the camel context declaration, server application starts up again. There seem to be 2 issues here:
1. Spring events are coming across to a Grails service even if it implements Spring's ApplicationListener interface. When looking into the code, it looks like Micronaut's ContextEventAdapter swallows the event because the Grails service doesn't get registered as a valid event listener for whatever reason. Again, this had all worked fine Grails 3.3.8.
2. If I create a plain vanilla listener for the application that extends ApplicationEventListener and does not look to utliize an injected Camel Context, it is able to listen to events. However, injecting a Camel context even with adding annotationProcessor("io.micronaut:micronaut-inject-java") into the build.gradle fails on injecting the Camel context. I have compile "org.apache.camel:camel-spring:${camelVersion}" in the build.gradle as well.

Appreciate any help on this.

Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.