Skip to content

NullPointerException in Hibernate when connecting to PostgreSQL: sqlExceptionHelper() returns null #36525

@JosephMasu

Description

@JosephMasu

Description:
When starting a Spring Boot application with Hibernate and PostgreSQL, I get the following error:

java.lang.NullPointerException: Cannot invoke "org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(java.sql.SQLException, String)"
because the return value of "org.hibernate.resource.transaction.backend.jdbc.internal.JdbcIsolationDelegate.sqlExceptionHelper()" is null

Steps to Reproduce:

Use Spring Boot 3.x with Hibernate 6.x
Configure PostgreSQL as follows:

application.properties:

spring.datasource.url=jdbc:postgresql://localhost:5432/testdb spring.datasource.username=testuser spring.datasource.password=testpass spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect spring.jpa.hibernate.ddl-auto=update

docker-compose.yml:

version: '3.9' services: postgres: image: postgres:16 environment: POSTGRES_USER: testuser POSTGRES_PASSWORD: testpass PGDATA: /data/postgres ports: - "5432:5432"

Start PostgreSQL container and run the Spring Boot app.

Expected Behavior:
Hibernate should connect to PostgreSQL and initialize the schema.

Actual Behavior:
Application fails immediately with a NullPointerException in Hibernate related to sqlExceptionHelper().

Environment:

macOS Ventura
Java 17
Spring Boot 3.3.2
Hibernate 6.x
PostgreSQL 16
Docker 24.x

Notes:

Verified that the database credentials and URL are correct.
Running PostgreSQL locally outside Docker works fine.
Error appears when using Dockerized PostgreSQL with Spring Boot running locally or in another container.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions