spring-projects / spring-ws

Spring Web Services
https://spring.io/projects/spring-ws
Apache License 2.0
321 stars 312 forks source link

Spring Boot 3.2.0 new warning about `DelegatingWsConfiguration is not eligible for getting processed by all BeanPostProcessors` #1391

Closed josephearl closed 6 months ago

josephearl commented 12 months ago

After upgrading to Spring Boot 3.2.0 our services that use spring-boot-starter-web-services now log a new warning on startup:

logger_name: org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker level: WARN

Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$SpringCGLIB$$0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). The currently created BeanPostProcessor [annotationActionEndpointMapping] is declared through a non-static factory method on that class; consider declaring it as static instead.

nikolay-hr commented 9 months ago

This message was info level in 3.1.x but now after 3.2.x is a warning - you can check the changes from here.

Auto-proxying is a mechanism in Spring AOP where Spring automatically creates proxy objects around your beans to add additional behavior, such as method interception for applying cross-cutting concerns like security, logging, etc.

The message indicates that the bean DelegatingWsConfiguration is not eligible for processing by all BeanPostProcessors. Specifically, it mentions that it's "not eligible for auto-proxying." After adding a @Bean for DelegatingWsConfiguration

@Bean
public DelegatingWsConfiguration delegatingWsConfiguration() {
     return new DelegatingWsConfiguration();
}

the warning disappears. Please don't take this as a solution @josephearl because it depends on what spring-boot-starter-web-services is used for ;)

Nestoter commented 9 months ago

This message was info level in 3.1.x but now after 3.2.x is a warning - you can check the changes from here.

Auto-proxying is a mechanism in Spring AOP where Spring automatically creates proxy objects around your beans to add additional behavior, such as method interception for applying cross-cutting concerns like security, logging, etc.

The message indicates that the bean DelegatingWsConfiguration is not eligible for processing by all BeanPostProcessors. Specifically, it mentions that it's "not eligible for auto-proxying." After adding a @Bean for DelegatingWsConfiguration

@Bean
public DelegatingWsConfiguration delegatingWsConfiguration() {
     return new DelegatingWsConfiguration();
}

the warning disappears. Please don't take this as a solution @josephearl because it depends on what spring-boot-starter-web-services is used for ;)

Hi @nikolay-hr , I have this same issue but i'm not able to find the class DelegatingWsConfiguration in my project. I think this is a springboot class and i cannot add the @Bean annotation. Where did you put that code snippet you provided?

nikolay-hr commented 9 months ago

Hi @Nestoter Yes it is from spring-boot project, using spring-boot-starter-web-services dependencies.

The parent of spring-boot-starter-web-services with spring-boot 3.2.2 is

<parent>
    <groupId>org.springframework.ws</groupId>
    <artifactId>spring-ws</artifactId>
    <version>4.0.8</version>
</parent>

You can find the source here - spring-ws-core

swiss-chris commented 5 months ago

Hello What's the recommended action for getting rid of this warning?

fischermatte commented 5 months ago

Hello What's the recommended action for getting rid of this warning?

Same question here, this warning still comes with Java 21, spring boot 3.2.5 and spring-ws 4.0.10

wilkinsona commented 5 months ago

I don't think this issue should have been closed. The warning message identifies that the cause of the problem is the annotationActionEndpointMapping bean:

2024-06-20T11:51:28.671+01:00  WARN   --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$SpringCGLIB$$0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). The currently created BeanPostProcessor [annotationActionEndpointMapping] is declared through a non-static factory method on that class; consider declaring it as static instead.

This bean is declared in Spring WS's WsConfigurationSupport:

https://github.com/spring-projects/spring-ws/blob/5e73b4c5549cec75a70b2f36c0647e1e82777df8/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurationSupport.java#L104-L113

As the warning describes, it's a BeanPostProcessor but the @Bean method is not static. This causes DelegatingWsConfiguration (a sub-class of WsConfigurationSupport) to be created very early so that the annotationActionEndpointMapping bean can be created and can perform its post-processing. This prevents DelegatingWsConfiguration itself from being post-processed.

WsConfiguration needs to be updated to declare annotationActionEndpointMapping as static.

72wildcard commented 4 months ago

@bclozel @corneil May I ask why this issue was closed?

hpoettker commented 4 months ago

I don't think the issue should be closed, but the problem is more complicated than it sounds in https://github.com/spring-projects/spring-ws/issues/1391#issuecomment-2180394331 above.

The method annotationActionEndpointMapping cannot be declared static as it calls the method getInterceptors, which isn't static. And these interceptors really come from injected WsConfigurers, so it is indeed a logical problem that AnnotationActionEndpointMapping is a BeanPostProcessor but depends itself on other beans.

Any solution will most likely require a breaking change.

leventunver commented 4 months ago

Hi @nikolay-hr, could you elaborate on why your solution shouldn't be used? Is it because of a concern that you have or is it because it may not work? You mentioned that it depends on what spring-boot-starter-web-services is used for but I didn't really understand what you mean by that.

nikolay-hr commented 4 months ago

Hi @leventunver. Defining a DelegatingWsConfiguration as a bean can help eliminate BeanPostProcessor warning, but it could not work in the future. Also applyBeanPostProcessorsAfterInitialization is deprecated since 6.1 and as you can see this is the entry point of where postProcessAfterInitialization is called.

tbuchloh commented 1 week ago

Why was this ticket closed? The warning is still present in Spring Boot 3.3.5.