# java.lang.ExceptionInInitializerError

**Code:** `ExceptionInInitializerError` · **Category:** Java · **Seen on:** Java

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/java/exceptionininitializererror)
