ExceptionInInitializerError ☕ Java

java.lang.ExceptionInInitializerError

A static initializer (static block or static field) threw an exception while the class was loading.

Seen on: Java

Meaning

The real cause is in “Caused by:”. After this the class is unusable, and later accesses throw NoClassDefFoundError: Could not initialize class.

Common causes

  • Static config reading a missing file/env var
  • Static field initialization throwing
  • Incompatible JDK/library (e.g. Lombok on new JDK)

⚡ Quick fix

  1. Read the “Caused by” section
  2. Move risky work out of static initializers
  3. Upgrade libraries for your JDK

Detailed fix by platform

Java

  1. Lazy-initialise heavy static resources instead of loading them in static blocks

How to diagnose

  1. Cause — What does Caused by say?
  2. Class — Which class failed to initialize?

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