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

Can't run app using Grails 6 and Spring Integration XML Gateway definition #13982

Open
ice1080 opened this issue Jan 24, 2025 · 2 comments
Open

Comments

@ice1080
Copy link

ice1080 commented Jan 24, 2025

Expected Behavior

Gateway definition in xml works correctly like in spring boot 2 and spring integration 5.

Actual Behaviour

App throws this error during startup:

The provided 'BeanDefinitionRegistry' must be an instance of 'ConfigurableBeanFactory' or 'ConfigurableApplicationContext', but given is: class org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry

Steps To Reproduce

  1. grails create-app
  2. create TestInterface with void send(Message message)
  3. add resources.xml with int:gateway definition in it, referring to testInterface
  4. ./gradlew bootRun

Commenting out the gateway definition in resources.xml causes the app to startup fine.

A workaround for this seems to be removing the gateway xml definition and defining the gateway interface like this instead:

import org.springframework.integration.annotation.Gateway
import org.springframework.integration.annotation.MessagingGateway
import org.springframework.messaging.Message

@MessagingGateway
interface TestInterface {
    @Gateway
    void send(Message message)
}

This isn't the best workaround for projects that have thousands of lines of spring integration xml definition.

Environment Information

  • Grails 6.2.3
  • Spring Integration 5.5.20
  • Operating System - tested on both Mac and Linux
  • JDK - 17.0.3
  • Groovy 3.0.13
  • Gradle 7.6.4

Example Application

https://github.com/ice1080/grails-spring-integration-xml

Version

6.2.3

@jdaugherty
Copy link
Contributor

The core code in question is located here:

SimpleBeanDefinitionRegistry beanRegistry = new SimpleBeanDefinitionRegistry();

It looks like this commit db4f120d in spring-integration is what causes this new error, it has this comment:

Functional gateway bean definitions

* Rework `MessagingGatewayRegistrar` to parse messaging gateway annotation
an `<gateway>` XML using a supplier variant for bean definition.
Such a feature is required by Spring Native - otherwise we would need to
register reflection info for to many internal Spring Integration classes
* Such a change should benefit from regular JDK perspective, too -
we don't do reflection for this kind of bean registrations

I assume that we can take the same approach as when we initialize the spring config and use the unrefreshedApplicationContext to load these beans. @codeconsole you're more familiar on the spring side. Do you have a suggestion on how to fix this?

As for a workaround, you should be able to remove the xml configuration & adopt the annotation based spring configuration @Configuration to work around this issue since it's specific to the registry we're using to load beans using the beanBuilder dsl.

@ice1080
Copy link
Author

ice1080 commented Jan 24, 2025

Ya I mentioned the workaround above, which is ok for this specific issue, but reworking all our thousands of lines of xml config into annotation based would be a pretty large effort that we might not be able to dedicate time to

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

No branches or pull requests

2 participants