spring-projects / spring-integration

Spring Integration provides an extension of the Spring programming model to support the well-known Enterprise Integration Patterns (EIP)
http://projects.spring.io/spring-integration/
Apache License 2.0
1.54k stars 1.11k forks source link

WARNING: An illegal reflective access operation has occurred #3765

Closed rdpagft closed 2 years ago

rdpagft commented 2 years ago

In what version(s) of Spring Integration are you seeing this issue?

For example:

5.3.18.RELEASE

Describe the bug

When I annotated with @MessagingGateway my interface and run my component I got "WARNING: An illegal reflective access operation has occurred".

To Reproduce

@MessagingGateway(defaultRequestChannel = "cesvivinOutboundChannel") public interface CesvivinOutboundPort { void produce (final Cesvivin cesvivin); }

@Configuration public class CesvivinOutboundConfig {

/**

Expected behavior

$ ./gradlew bootRun

Task :bootRun 2022-04-01 18:32:54.447 INFO 32112 --- [ main] m.c.a.o.v.AmisOcraVehiculosApplication : Starting AmisOcraVehiculosApplication using Java 11.0.12 on GFT-LdMkK0zFBuM with PID 32112 (C:\Users\rdpa\Documents\amis-ocra-vehiculos\build\classes\java\main started by rdpa in C:\Users\rdpa\Documents\amis-ocra-vehiculos) 2022-04-01 18:32:54.451 INFO 32112 --- [ main] m.c.a.o.v.AmisOcraVehiculosApplication : No active profile set, falling back to 1 default profile: "default" 2022-04-01 18:32:55.339 INFO 32112 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode! 2022-04-01 18:32:55.341 INFO 32112 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode. 2022-04-01 18:32:55.357 INFO 32112 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 7 ms. Found 0 Redis repository interfaces. 2022-04-01 18:32:55.465 INFO 32112 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created. 2022-04-01 18:32:55.473 INFO 32112 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created. 2022-04-01 18:32:55.568 INFO 32112 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=8e8d7b38-bea2-3475-b570-a65eddb385d4 2022-04-01 18:32:55.611 INFO 32112 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'validationConfig' of type [mx.com.amis.ocra.chasis.config.ValidationConfig$$EnhancerBySpringCGLIB$$6e2fb28e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2022-04-01 18:32:55.622 INFO 32112 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'validator' of type [org.springframework.validation.beanvalidation.LocalValidatorFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2022-04-01 18:32:55.815 INFO 32112 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationChannelResolver' of type [org.springframework.integration.support.channel.BeanFactoryChannelResolver] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2022-04-01 18:32:55.834 INFO 32112 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.integration.config.IntegrationManagementConfiguration' of type [org.springframework.integration.config.IntegrationManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2022-04-01 18:32:56.392 INFO 32112 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8005 (http) 2022-04-01 18:32:56.399 INFO 32112 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2022-04-01 18:32:56.400 INFO 32112 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.60] 2022-04-01 18:32:56.497 INFO 32112 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2022-04-01 18:32:56.497 INFO 32112 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2003 ms 2022-04-01 18:32:57.256 INFO 32112 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Will not secure any request 2022-04-01 18:32:57.344 INFO 32112 --- [ main] c.g.c.s.a.c.GcpContextAutoConfiguration : The default project ID is amis-ocra-dev 2022-04-01 18:32:57.369 WARN 32112 --- [ main] c.g.a.oauth2.DefaultCredentialsProvider : Your application has authenticated using end user credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see https://cloud.google.com/docs/authentication/. 2022-04-01 18:32:57.372 INFO 32112 --- [ main] c.g.c.s.core.DefaultCredentialsProvider : Default credentials provider for user 764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.apps.googleusercontent.com 2022-04-01 18:32:57.372 INFO 32112 --- [ main] c.g.c.s.core.DefaultCredentialsProvider : Scopes in use by default credentials: [https://www.googleapis.com/auth/pubsub, https://www.googleapis.com/auth/spanner.admin, https://www.googleapis.com/auth/spanner.data, https://www.googleapis.com/auth/datastore, https://www.googleapis.com/auth/sqlservice.admin, https://www.googleapis.com/auth/devstorage.read_only, https://www.googleapis.com/auth/devstorage.read_write, https://www.googleapis.com/auth/cloudruntimeconfig, https://www.googleapis.com/auth/trace.append, https://www.googleapis.com/auth/cloud-platform, https://www.googleapis.com/auth/cloud-vision, https://www.googleapis.com/auth/bigquery, https://www.googleapis.com/auth/monitoring.write] WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.util.ReflectionUtils (file:/C:/Users/rdpa/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.3.18/7ff3000f3342989cb011b6095a0e86f2e5176cef/spring-core-5.3.18.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class) WARNING: Please consider reporting this to the maintainers of org.springframework.util.ReflectionUtils WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 2022-04-01 18:33:00.797 INFO 32112 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint(s) beneath base path '/actuator' 2022-04-01 18:33:00.951 INFO 32112 --- [ main] o.s.i.endpoint.EventDrivenConsumer : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel 2022-04-01 18:33:00.952 INFO 32112 --- [ main] o.s.i.channel.PublishSubscribeChannel : Channel 'amis-ocra-vehiculos.errorChannel' has 1 subscriber(s). 2022-04-01 18:33:00.952 INFO 32112 --- [ main] o.s.i.endpoint.EventDrivenConsumer : started bean '_org.springframework.integration.errorLogger' 2022-04-01 18:33:00.952 INFO 32112 --- [ main] o.s.i.endpoint.EventDrivenConsumer : Adding {message-handler:cesvivinOutboundConfig.sender.serviceActivator} as a subscriber to the 'cesvivinOutboundChannel' channel 2022-04-01 18:33:00.952 INFO 32112 --- [ main] o.s.i.channel.PublishSubscribeChannel : Channel 'amis-ocra-vehiculos.cesvivinOutboundChannel' has 1 subscriber(s). 2022-04-01 18:33:00.952 INFO 32112 --- [ main] o.s.i.endpoint.EventDrivenConsumer : started bean 'cesvivinOutboundConfig.sender.serviceActivator' 2022-04-01 18:33:00.952 INFO 32112 --- [ main] ProxyFactoryBean$MethodInvocationGateway : started bean 'cesvivinOutboundPort#produce(Cesvivin)' 2022-04-01 18:33:00.952 INFO 32112 --- [ main] o.s.i.gateway.GatewayProxyFactoryBean : started bean 'cesvivinOutboundPort' 2022-04-01 18:33:00.962 INFO 32112 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8005 (http) with context path '' 2022-04-01 18:33:01.271 INFO 32112 --- [ main] m.c.a.o.v.AmisOcraVehiculosApplication : Started AmisOcraVehiculosApplication in 7.462 seconds (JVM running for 7.868)

artembilan commented 2 years ago

This has nothing to do with Spring Integration. See that log carefully around spring-core. There are many similar reports: https://github.com/spring-projects/spring-framework/issues?q=is%3Aissue+An+illegal+reflective+access+operation+has+occurred.

A general answer: such a warning is going to disappear itself when some future Java version will release possible reflection replacement for those features.

Closed as Invalid.

rdpagft commented 2 years ago

Thank you for your comments @artembilan

peergynt commented 2 years ago

Hi @artembilan. I came across the same issue with Spring Boot 2.6.6, Spring Integration 5.5.10 on JDK 11. You mention that such a warning is going to disappear itself but I wonder if this is the case.

I found a very similar issue that was opened in Spring Data: https://github.com/spring-projects/spring-data-commons/issues/1811 The Spring Data issue was in their implementation of DefaultMethodInvokingMethodInterceptor. The Spring Data team pushed a fix for this: https://github.com/spring-projects/spring-data-commons/pull/307/commits/80dc64b8c142e971333a9a080593cbb94cd06877

I believe that the issue reported here occurs in: https://github.com/spring-projects/spring-integration/blob/main/spring-integration-core/src/main/java/org/springframework/integration/gateway/DefaultMethodInvokingMethodInterceptor.java

Does it make sense to reopen this issue and consider a change similar to what was done in Spring Data?

artembilan commented 2 years ago

Sure! I see what you mean.

Spring Data has fixed it via their own Lazy abstraction do not call ctor = Lookup.class.getDeclaredConstructor(Class.class); eagerly if privateLookupIn is already available.

Let me see what we can do over here is Spring Integration.

Thank you!

peergynt commented 2 years ago

Thank you for the quick turnaround @artembilan , appreciate it!