IllegalArgumentException ☕ Java

java.lang.IllegalArgumentException

A method rejected an argument value as invalid.

Seen on: Java

Meaning

It’s a generic exception thrown by libraries and your own validation. The message (and the method in the stack trace) tells you which argument and why.

Common causes

  • Invalid enum name in Enum.valueOf
  • Null/empty values where not allowed
  • Out-of-range numbers
  • Spring: missing -parameters flag for @PathVariable names

⚡ Quick fix

  1. Read the message and the method that threw it
  2. Validate inputs before calling
  3. Use Enum lookups that handle unknown values

Detailed fix by platform

Java

  1. Spring Boot 3.2+: compile with -parameters (Maven compiler plugin parameters=true) or name @RequestParam/@PathVariable explicitly

How to diagnose

  1. Method — Which method threw it?
  2. Value — Which argument value?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.