Spring cannot name a @RequestParam or @PathVariable argument without -parameters
Your error
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.1 more line it can showFix it fast
Most common cause, 1 of 3The Gradle module is compiled without -parameters
Add the flag to the JavaCompile tasks of every module that holds Spring components, or apply the Spring Boot plugin there.
// build.gradle.kts of the module with the controllers
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.add("-parameters")
}
// or name the argument explicitly
@GetMapping("/search")
List<Item> search(@RequestParam("q") String q) { ... }Short answer
Name for argument of type [java.lang.String] not specified, and parameter name information not available via reflection appears because Spring Framework 6.1 removed bytecode-based name lookup. Compile with javac -parameters (the Spring Boot Gradle plugin adds it, plain JavaCompile tasks and IDE builds may not), use -java-parameters for Kotlin, or write @RequestParam("name"). Spring Framework 6.1 to 7.1.
Which cause do you have?
Check whether the compiled controller class carries parameter names. javac -parameters stores them in the class file as a MethodParameters attribute, which javap -v prints; no such attribute means the build that produced this class left the flag out.
./gradlew compileJava
javap -v -cp build/classes/java/main com.example.web.SearchController | grep -A3 MethodParametersThen find the line you see in this list and open its fix:
- 1The Gradle module is compiled without -parameters
javap shows no MethodParameters, and the module's build file does not apply the org.springframework.boot plugin (a library or web module in a multi-module build) - 2The IDE compiles the classes itself, without the flag
./gradlew bootRun works, but running the application class from IntelliJ IDEA, Eclipse or VS Code fails with the same exception - 3Kotlin code is compiled without -java-parameters
The failing controller is a Kotlin class, and its module does not apply the Spring Boot plugin
What does the error look like?
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.Name for argument of type [java.lang.String] not specified, and parameter name information not found in class file either.
Cause 1 of 3
The Gradle module is compiled without -parameters
You seejavap shows no MethodParameters, and the module's build file does not apply the org.springframework.boot plugin (a library or web module in a multi-module build)
Check
Spring Framework 6.1 dropped LocalVariableTableParameterNameDiscoverer, so an unnamed @RequestParam, @PathVariable or @RequestHeader argument gets its name only from reflection, which needs javac -parameters. The Spring Boot Gradle plugin adds that flag to every JavaCompile task when it is applied, but a module that only imports the Boot BOM or uses the dependency-management plugin compiles without it, so its controllers fail once the build moves to Spring Framework 6.1 or newer, which Spring Boot 3.2 brought in.
grep -n "org.springframework.boot\|compilerArgs" build.gradle* */build.gradle*Fix
Add the flag to the JavaCompile tasks of every module that holds Spring components, or apply the Spring Boot plugin there. If only a few arguments are affected, naming them in the annotation also works.
// build.gradle.kts of the module with the controllers
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.add("-parameters")
}
// or name the argument explicitly
@GetMapping("/search")
List<Item> search(@RequestParam("q") String q) { ... }Verify
javap now prints a MethodParameters block, and the endpoint answers instead of returning the 500 error.
./gradlew clean compileJava
javap -v -cp build/classes/java/main com.example.web.SearchController | grep -A3 MethodParametersConfirmed by github.com
Cause 2 of 3
The IDE compiles the classes itself, without the flag
You see./gradlew bootRun works, but running the application class from IntelliJ IDEA, Eclipse or VS Code fails with the same exception
Check
When the IDE compiles the classes with its own compiler settings, the -parameters argument from the build script may not reach it, and the classes it writes lack parameter names. The Spring 6.1 release notes say that configuring the IDE by hand is sometimes needed for this reason.
./gradlew bootRun
curl -i "http://localhost:8080/search?q=test" # works here, fails from the IDE run buttonFix
Turn the flag on in the IDE, then rebuild the project so old class files are replaced. IntelliJ IDEA: Settings, Build, Execution, Deployment, Compiler, Java Compiler, Additional command line parameters: -parameters. Eclipse: Preferences, Java, Compiler, Store information about method parameters (usable via reflection). VS Code: the line below in .settings/org.eclipse.jdt.core.prefs.
# .settings/org.eclipse.jdt.core.prefs (VS Code / Eclipse JDT)
org.eclipse.jdt.core.compiler.codegen.methodParameters=generateVerify
After a full rebuild in the IDE, start the application from the IDE and call the endpoint; it returns data.
curl -i "http://localhost:8080/search?q=test"Confirmed by github.com
Cause 3 of 3
Kotlin code is compiled without -java-parameters
You seeThe failing controller is a Kotlin class, and its module does not apply the Spring Boot plugin
Check
Kotlin does not use the javac flag. Its equivalent is -java-parameters, exposed in the Kotlin Gradle plugin as the javaParameters compiler option, which defaults to false. The Spring Boot plugin switches it on for KotlinCompile tasks only in modules where it is applied.
grep -n "javaParameters\|java-parameters" build.gradle.kts */build.gradle.ktsFix
Enable javaParameters in the kotlin block of each Kotlin module with Spring components.
// build.gradle.kts
kotlin {
compilerOptions {
javaParameters.set(true)
}
}Verify
Rebuild and call the endpoint again; the argument binds by its Kotlin parameter name.
./gradlew clean build
curl -i "http://localhost:8080/search?q=test"Confirmed by kotlinlang.org
How do I stop it coming back?
- Put the -parameters compiler argument in a shared convention plugin or the root build so every module, not only the one with the Boot plugin, gets it.
- Name request parameters, path variables and headers in the annotation on public API controllers; the mapping then survives any compiler setting.
- Write the IDE compiler setting for -parameters into the team's setup notes (or commit .settings/org.eclipse.jdt.core.prefs), so IDE runs behave like CI.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: QistLock, Dispatch Pro, Nuclear Home Video.