I have a problem running wildfly and postgres in two seperate containers (but both within one pod) using podman.
The general structure is:
- 2 pods (one wildfly and one postgres container) run within one pod
- the postgres port is exposed as 5433 (set by podman)
- wildfly tries to establish a connection with the postgres server (specified in persistence.xml and film-ds.xml)
- the postgres.jar is the JDBC driver for the postgres db and is located in wildfly -> deployments
Whenever I try to start the wildfly server (after the postgres is alredy up) I get the following exception:
Caused by: org.postgresql.util.PSQLException: Connection to localhost:5433 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
Can someone help me fixing this error?
The contents of the important files:
film-ds.xml: (located in wildfly -> deployments)
<datasource jndi-name="java:jboss/datasources/filmDS" pool-name="film" enabled="true" use-java-context="true">
<connection-url>jdbc:postgresql://localhost:5433/dvdrentalfilm</connection-url>
<driver>postgres.jar</driver>
<security>
<user-name>postgres</user-name>
<password>*******</password>
</security>
</datasource>
persistence.xml: (shipped with the war file in wildfly -> deployments)
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation= "http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" version="2.1">
<persistence-unit name="default">
<jta-data-source>java:jboss/datasources/filmDS</jta-data-source>
...
</persistence-unit>
setup.sh: (sets up the pods and containers)
podman pod create --name dvd --share cgroup,ipc,uts
podman build . -f film -t filmjavaimg
podman build . -f filmDB -t filmdbimg
podman run -p 5433:5432 -d --pod dvd --name filmDB filmdbimg
while ! nc -w 1 -z localhost 5433; do sleep 1; echo "Waiting for Postgres (Film)..."; done
podman run -p 5433:8080 -d --pod dvd filmjavaimg
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…