#Docker Postgress error

1 messages · Page 1 of 1 (latest)

scenic garnet
#

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
facing this
and my docker container is running on

CONTAINER ID   IMAGE             COMMAND                  CREATED          STATUS         PORTS                      NAMES
9a997276004b   postgres:latest   "docker-entrypoint.s…"   18 minutes ago   Up 4 minutes   0.0.0.0:5432->5432/tcp POSTGRESQL_NEW

on my custom network i.e

NETWORK ID     NAME             DRIVER    SCOPE
b997c2ee3490   spring-network   bridge    local

yaml configs

  datasource:
    url: jdbc:postgresql://POSTGRESQL_NEW:5432/pdfs
    username: postgres
    password: admin#123
    driver-class-name: org.postgresql.Driver
  jpa:
    hibernate:
       properties:
           dialect: org.hibernate.dialect.PostgreSQLDialect
       ddl-auto: update
       show_sql: true

i used
docker run --name POSTGRESQL_NEW -e POSTGRES_PASSWORD=admin#123 -p 5432:5432 -d postgres:latest
this command to run container and docker network connect spring-network POSTGRESQL_NEW this to connect to my network

toxic badgerBOT
#

<@&987246584574140416> please have a look, thanks.

scenic garnet
#
[
    {
        "Name": "spring-network",
        "Id": "b997c2ee3490cded35fca58d97b37df7aa260c3133db4731974d8a5d3e1fad68",
        "Created": "2024-07-27T11:05:33.06338683Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.19.0.0/16",
                    "Gateway": "172.19.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "9a997276004bfced19f092cad4e16bf2c764df59866f92cd81364521d1e09547": {
                "Name": "POSTGRESQL_NEW",
                "EndpointID": "44e82501c02096ce40de5a2575c80bf69b549d8c620b7e17aa008953467953a5",
                "MacAddress": "02:42:ac:13:00:02",
                "IPv4Address": "172.19.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]
#

network stats

#

kindly see @last quail

#

I am facing this issue while using

mvn package
karmic vapor
#

You're not running your Spring server through docker are you? If not, since you're exposing the container ports on 5432 the connection url should be

localhost and not POSTGRESQL_NEW.

POSTGRESQL_NEW is only if services are both running the Docker

scenic garnet
#

If I use localhost then it is not running on docker

karmic vapor
#

How are you running your backend? Because on that docker ps you did I only see the Postgres database running?

scenic garnet
sacred dove
#

Darth is right how do you run springboot?

#

Can you ping POSTGRESQL_NEW from the CLI where you run spring?

charred quail
#

can you post your Dockerfile

#

also you might need to create a network - can't remember from the top of my head though

sacred dove
charred quail
#

yup

sacred dove
#

Imo docker is best using the IPvlan network driver

#

I pref to manage networks in my router

#

But that involves a rather compicated setup

karmic vapor
#

The name POSTGRES_NEW is only recognized as a name inside Docker, its used for service discovery. So unless you explicitly build and compile that Jar into a Docker container you won’t be able to use that

scenic garnet
scenic garnet
sacred dove
scenic garnet
#
LABEL maintainer = "ayanFile.net"
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java", "-jar","/app.jar"]```
scenic garnet
sacred dove
#

goto: Let’s also take a peak at our docker compose file:

charred quail
#

it needs to be on the same network as your postgres

sacred dove
#

I would suggest setting up compose

charred quail
#

you also need to expose your ports if you want the public accessing ur api

sacred dove
#

It makes this easier to understand

#

You'll have a single source of truth for network setups, isntead of splitting the network config into multiple places

#

I would highly recommend to avoid splitting configurations, if you're not sure on what you're doing. If you have multiple configs to manage, you'll loose track of things fast

last quail
#

I'm also a bit unsure if you're using Spring Boot why you're not just using testcontainers?