☕ Java errors

Java and JVM exceptions: NullPointerException, ClassNotFoundException, OutOfMemoryError.

CodeErrorWhat it means
Maven resolve [ERROR] Failed to execute goal on project x: Could not resolve dependencies for project Maven couldn’t download or find one or more dependencies.
release version not supported [ERROR] Fatal error compiling: error: release version 17 not supported The JDK running Maven is older than the Java version the project compiles for.
InvalidDefinitionException com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class X and no properties discovered Jackson can’t serialize the class — it has no public getters/fields, or it’s a Hibernate proxy, or Java 8 dat…
MismatchedInputException com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.util.ArrayList` from Object value Jackson found JSON whose shape doesn’t match the target Java type (object vs array, string vs number, missing…
UnrecognizedPropertyException com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "x", not marked as ignorable The JSON contains a field your Java class doesn’t have, and Jackson is configured to fail on unknown properti…
Communications link failure com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The MySQL JDBC driver couldn’t reach the database (or the connection dropped).
Gradle wrapper main class Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain The Gradle wrapper JAR (gradle/wrapper/gradle-wrapper.jar) is missing or corrupt.
JAVA_HOME not set ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Build tools (Gradle, Maven, Android tools) can’t find a JDK.
DataSource url not specified Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Spring Boot found JDBC/JPA on the classpath but no database URL.
HikariCP timeout HikariPool-1 - Connection is not available, request timed out after 30000ms The connection pool was exhausted — all connections were busy for 30 seconds.
HttpMessageNotReadableException HttpMessageNotReadableException: JSON parse error / Required request body is missing Spring couldn’t read the request body into your @RequestBody object.
NonUniqueResultException IncorrectResultSizeDataAccessException: query did not return a unique result: 2 A query expected one row but found several.
FileNotFoundException java.io.FileNotFoundException: config.properties (No such file or directory) Java couldn’t open the file — wrong path relative to the working directory, missing file, or a classpath reso…
Stream closed java.io.IOException: Stream closed Code read or wrote a stream after it was closed — often by a try-with-resources block or a wrapper closing th…
ArithmeticException java.lang.ArithmeticException: / by zero Integer division or modulo by zero.
ArrayIndexOutOfBoundsException java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5 Code accessed an array index outside 0 … length-1.
ClassCastException java.lang.ClassCastException: class A cannot be cast to class B An object was cast to a type it isn’t.
ClassNotFoundException java.lang.ClassNotFoundException / NoClassDefFoundError The JVM couldn’t find a class on the classpath at runtime.
ExceptionInInitializerError java.lang.ExceptionInInitializerError A static initializer (static block or static field) threw an exception while the class was loading.
IllegalArgumentException java.lang.IllegalArgumentException A method rejected an argument value as invalid.
IllegalStateException java.lang.IllegalStateException A method was called when the object wasn’t in the right state for it.
InterruptedException java.lang.InterruptedException (sleep interrupted) A blocked thread (sleep, wait, join, queue take) was interrupted by another thread.
NoSuchMethodError java.lang.NoSuchMethodError Code compiled against one version of a library is running with another version where the method doesn’t exist.
NullPointerException java.lang.NullPointerException Code called a method or accessed a field on a reference that is `null`.
NumberFormatException java.lang.NumberFormatException: For input string: "x" A string couldn’t be parsed as a number — it’s empty, has spaces/commas, is too large, or isn’t numeric.
OutOfMemoryError java.lang.OutOfMemoryError: Java heap space The JVM ran out of heap memory and garbage collection couldn’t free enough.
StackOverflowError java.lang.StackOverflowError The thread’s call stack overflowed — almost always unbounded recursion, sometimes a bidirectional toString/eq…
StringIndexOutOfBoundsException java.lang.StringIndexOutOfBoundsException: begin 0, end 10, length 5 substring()/charAt() used an index outside the string.
UnsupportedClassVersionError java.lang.UnsupportedClassVersionError: class file version 61.0, this version of the Java Runtime only recognizes up to 55.0 Code compiled for a newer Java version is running on an older JVM.
UnsupportedOperationException java.lang.UnsupportedOperationException (List.of / Arrays.asList is immutable) Code tried to modify an immutable or fixed-size collection.
ConnectException java.net.ConnectException: Connection refused Nothing is listening at the host:port the Java client connected to.
SocketException reset java.net.SocketException: Connection reset The remote side closed the TCP connection abruptly while Java was reading or writing.
UnknownHostException java.net.UnknownHostException: api.example.com DNS resolution failed for the hostname.
AccessDeniedException java.nio.file.AccessDeniedException: /path The OS denied a file operation to the Java process.
NoSuchFileException java.nio.file.NoSuchFileException: /path/file An NIO Files operation targeted a path that doesn’t exist.
Unparseable date java.text.ParseException: Unparseable date: "x" SimpleDateFormat couldn’t parse the string with its pattern.
DateTimeParseException java.time.format.DateTimeParseException: Text '31/12/2024' could not be parsed at index 2 A java.time parse call got text that doesn’t match the expected format.
TimeoutException java.util.concurrent.TimeoutException A Future.get(timeout) or async operation didn’t complete in the allowed time.
ConcurrentModificationException java.util.ConcurrentModificationException A collection was modified while being iterated (even in a single thread).
InputMismatchException java.util.InputMismatchException (Scanner) Scanner.nextInt()/nextDouble() read a token that isn’t that type.
NoSuchElementException java.util.NoSuchElementException: No value present Code asked for an element that doesn’t exist — Optional.get() on empty, iterator.next() past the end, Scanner…
PKIX path building failed javax.net.ssl.SSLHandshakeException: PKIX path building failed: unable to find valid certification path to requested target Java doesn’t trust the server’s certificate chain (self-signed, corporate proxy CA, or missing intermediate).
MethodArgumentNotValidException MethodArgumentNotValidException: Validation failed for argument [0] Bean Validation (@Valid with @NotNull, @Email, @Size…) rejected the request body.
Hibernate ConstraintViolationException org.hibernate.exception.ConstraintViolationException: could not execute statement The database rejected an insert/update because of a constraint (unique, foreign key, not null).
LazyInitializationException org.hibernate.LazyInitializationException: could not initialize proxy - no Session A lazy-loaded association was accessed after the Hibernate session/transaction closed.
TransientObjectException org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing An entity references another entity that hasn’t been saved yet, and no cascade is configured.
circular references The dependencies of some of the beans in the application context form a cycle Two or more Spring beans depend on each other through constructors, and Spring Boot 2.6+ forbids cycles by de…
UnsatisfiedDependencyException UnsatisfiedDependencyException / NoSuchBeanDefinitionException: No qualifying bean of type 'X' available Spring couldn’t find (or choose) a bean to inject.
Port 8080 in use Web server failed to start. Port 8080 was already in use. Spring Boot couldn’t bind its embedded server port because another process uses it.
Whitelabel Error Page Whitelabel Error Page — This application has no explicit mapping for /error Spring Boot’s default error page — the request hit no controller mapping (404) or a controller threw (500).