IllegalArgumentException Java Origin: Application & API Last updated 13 Oct 2026

java.lang.IllegalArgumentException

A method rejected an argument value as invalid.

Exact message you may see No enum constant
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 not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

1048 — MySQL ERROR 1048 (23000): Column 'x' cannot be null (MySQL)1048422 — HTTP 422 Unprocessable Content (HTTP)422ArithmeticException — java.lang.ArithmeticException: / by zero (Java)ArithmeticExceptionCastError ObjectId — CastError: Cast to ObjectId failed for value "x" (type string) at path "_id" (Node.js)CastError ObjectIdDocument failed validation — MongoDB: MongoServerError: Document failed validation (code 121) (MongoDB)Document failed valid…error converting YAML to JSON — error converting YAML to JSON: yaml: line 12: did not find expected key (Kubernetes)error converting YAML…IllegalStateException — java.lang.IllegalStateException (Java)IllegalStateExceptionIndex was out of range — ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection (.NET)Index was out of rangeIllegalAr…

Explore the map of this error Full error map →

🧠 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.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.