Skip to content

WARNING: An illegal reflective access operation has occurred #3765

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

Closed
rdpagft opened this issue Apr 2, 2022 · 5 comments · Fixed by #3781
Closed

WARNING: An illegal reflective access operation has occurred #3765

rdpagft opened this issue Apr 2, 2022 · 5 comments · Fixed by #3781

Comments

@rdpagft
Copy link

rdpagft commented Apr 2, 2022

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 {

/**

  • Nombre de la suscripción del tópico para registrar alta de robo.
    */
    @value("${topic.cesvivn.name}")
    private String topic;

/**

  • Método que configura un bean como estrategia de canal.
  • @return Una lista {@link List} de objetos tipo {@link MessageChannel}.
    */
    @bean
    public MessageChannel cesvivinOutboundChannel () {
    return new PublishSubscribeChannel();
    }

/**

  • Método que configura un bean como para adaptar el canal de salida.
  • @param pubSubTemplate Implementación de patrón template para suscribir o publicar objetos en el contexto de Cloud Pub/Sub.
  • @return Una instancia de tipo {@link MessageHandler}.
    */
    @bean
    @serviceactivator(inputChannel = "cesvivinOutboundChannel")
    public MessageHandler sender (final PubSubTemplate pubSubTemplate) {
    return new PubSubMessageHandler(pubSubTemplate, topic);
    }

/**

  • Método que configura un bean como estrategia de serialización entre objetos java y cadenas que provienen del payload de mensajes.
  • @return Una instancia de tipo {@link PubSubMessageConverter}.
    */
    @bean
    public PubSubMessageConverter pubSubMessageConverter () {
    return new JacksonPubSubMessageConverter(new ObjectMapper());
    }
    }

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)

@rdpagft rdpagft added status: waiting-for-triage The issue need to be evaluated and its future decided type: bug labels Apr 2, 2022
@artembilan
Copy link
Member

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.

@artembilan artembilan added status: invalid Not reproducable or not relevant to the current state of the project and removed type: bug status: waiting-for-triage The issue need to be evaluated and its future decided labels Apr 4, 2022
@rdpagft
Copy link
Author

rdpagft commented Apr 4, 2022

Thank you for your comments @artembilan

@peergynt
Copy link

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: spring-projects/spring-data-commons#1811
The Spring Data issue was in their implementation of DefaultMethodInvokingMethodInterceptor.
The Spring Data team pushed a fix for this: spring-projects/spring-data-commons@80dc64b

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
Copy link
Member

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!

@artembilan artembilan reopened this Apr 11, 2022
@artembilan artembilan added type: bug in: core backport 5.5.x and removed status: invalid Not reproducable or not relevant to the current state of the project labels Apr 11, 2022
@artembilan artembilan added this to the 6.0 M3 milestone Apr 11, 2022
artembilan added a commit to artembilan/spring-integration that referenced this issue Apr 11, 2022
Fixes spring-projects#3765

The `DefaultMethodInvokingMethodInterceptor` has several strategies
for `default` method invocations in the messaging gateway.
One of them is based on the `Lookup` constructor which causes
a `WARNING: An illegal reflective access operation has occurred`.
This can be done lazily when there is no `MethodHandles.privateLookupIn`
in Java version used for the project.

* Fix `OPEN` enum value for the `Constructor<Lookup>` to be resolved in
a lazy manner via `Supplier` and `boolean` flag

**Cherry-pick to `5.5.x`**
garyrussell pushed a commit that referenced this issue Apr 11, 2022
Fixes #3765

The `DefaultMethodInvokingMethodInterceptor` has several strategies
for `default` method invocations in the messaging gateway.
One of them is based on the `Lookup` constructor which causes
a `WARNING: An illegal reflective access operation has occurred`.
This can be done lazily when there is no `MethodHandles.privateLookupIn`
in Java version used for the project.

* Fix `OPEN` enum value for the `Constructor<Lookup>` to be resolved in
a lazy manner via `Supplier` and `boolean` flag

**Cherry-pick to `5.5.x`**
garyrussell pushed a commit that referenced this issue Apr 11, 2022
Fixes #3765

The `DefaultMethodInvokingMethodInterceptor` has several strategies
for `default` method invocations in the messaging gateway.
One of them is based on the `Lookup` constructor which causes
a `WARNING: An illegal reflective access operation has occurred`.
This can be done lazily when there is no `MethodHandles.privateLookupIn`
in Java version used for the project.

* Fix `OPEN` enum value for the `Constructor<Lookup>` to be resolved in
a lazy manner via `Supplier` and `boolean` flag

**Cherry-pick to `5.5.x`**
@peergynt
Copy link

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

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

Successfully merging a pull request may close this issue.

3 participants