spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
55.27k stars 37.62k forks source link

Null key returned for cache operation and Parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag. #32715

Closed manjinderrooprai closed 2 weeks ago

manjinderrooprai commented 2 weeks ago

On updating our application to Spring Boot 3.2.5 and Spring framework 6.1.6. we are getting following Errors.

ERROR c.a.s.t.c.e.ControllerExceptionHandler - java.lang.IllegalArgumentException: Name for argument of type [java.lang.String] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag.
java.lang.IllegalArgumentException: Name for argument of type [java.lang.String] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag.
ERROR c.a.s.t.c.e.ControllerExceptionHandler - java.lang.IllegalArgumentException: Null key returned for cache operation  caches=['cacheExample'] | key='#cacheKey' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='true']. If you are using named parameters, ensure that the compiler uses the '-parameters' flag.
java.lang.IllegalArgumentException: Null key returned for cache operation  caches=['cacheExample'] | key='#cacheKey' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='true']. If you are using named parameters, ensure that the compiler uses the '-parameters' flag.

It seams, it is asking to compile(java) code with '-parameters' flag. So for that, I have followed the directions on https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x#parameter-name-retention:

I have added:

tasks.withType(JavaCompile).configureEach {
    options.compilerArgs.add("-parameters")
}

Even i had tried adding following mentioned in Thread: https://github.com/spring-projects/spring-framework/issues/31729

 tasks.withType(JavaCompile) {
        configure(options) {
            options.compilerArgs << '-parameters'
        }
    }

Nothing works for me.

I am using Vscode 1.88.1 with following configuration: springBootVersion= 3.2.5 springFrameworkVersion= 6.1.6 Java= 17.0.5 gradle= 8.7

Could you please help me in resolving this issue.

Affects: \


snicoll commented 2 weeks ago

Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.

manjinderrooprai commented 2 weeks ago

Raised the concern in Stack Overflow

https://stackoverflow.com/questions/78392713/null-key-returned-for-cache-operation-parameter-name-information-not-available