javadockerhibernatemavenwildfly

Communications link failure when trying to connect Wildfly Docker Container to MySQL Docker Container


Context

I'm trying to containerize my jakarta EE application. But I'm having issues connecting to the database container from the container that my wildfly server is running on.

The application consists of:

Everything works locally. And I have managed to containerize the frontend and database without issues. I have even tested to deploy my wildfly server locally (through intelliJ war:exploded) and connect to the frontend and database containers, and that works ok.

Problem

When I try to containerize my wildfly server and start it up it fails with a long list of errors including:

Steps taken to containerize Wildfly

Step 1: Created Dockerfile:

FROM quay.io/wildfly/wildfly

COPY ./wildfly-config/com /opt/jboss/wildfly/modules/com

COPY ./wildfly-config/config-script.cli /opt/jboss/config-script.cli

COPY ./wildfly-config/logging-script.cli /opt/jboss/logging-script.cli

RUN /opt/jboss/wildfly/bin/jboss-cli.sh --file=/opt/jboss/logging-script.cli

RUN /opt/jboss/wildfly/bin/jboss-cli.sh --file=/opt/jboss/config-script.cli

RUN rm -Rf /opt/jboss/wildfly/standalone/configuration/standalone_xml_history/*

RUN /opt/jboss/wildfly/bin/add-user.sh admin test1234

WORKDIR /opt/jboss/wildfly/standalone/deployments

COPY ./target/SusFund-1.0-SNAPSHOT.war ./SusFund-1.0-SNAPSHOT.war

CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0", "--debug"]

(Note: ./wildfly-config/com contains com/mysql/main/module.xml and mysql-connector-j-9.2.0.jar)

Step 2: Added config-script.cli to modify standalone.xml

embed-server --server-config=standalone.xml --std-out=echo

batch

/subsystem="datasources"/data-source="MySQLDS":add(\
  connection-url="jdbc:mysql://db:7777/susfund_db", \
  driver-name="mysql", \
  enabled="true", \
  jndi-name="java:/jdbc/MySQLDataSource")

/subsystem="datasources"/jdbc-driver="mysql":add(\
    driver-name="mysql", \
    driver-module-name="com.mysql", \
    driver-class-name="com.mysql.cj.jdbc.Driver")

run-batch

Step 3: Set root password in Database Dockerfile

FROM mysql:latest

ENV MYSQL_ROOT_PASSWORD=test1234

COPY ./scripts/dbinit.sql /docker-entrypoint-initdb.d/

Step 4: Setup persistence unit in persistence.xml so that it is coherent with standalone.xml after script is run:

 <persistence-unit name="myUnit" transaction-type="JTA">
        <jta-data-source>jdbc/MySQLDataSource</jta-data-source>
        <properties>
            <property name="hibernate.show_sql" value="true"/>
            <property name="jakarta.persistence.jdbc.user"   value="root" />
            <property name="jakarta.persistence.jdbc.password" value="test1234" />
        </properties>
    </persistence-unit>

Step 5: Create docker-compose.yml file with same network so that i can use "db:7777" name in connection-url in standalone.xml

services:
  susfund-fe:
    container_name: susfund-fe
    build:
      context: .
      dockerfile: Dockerfile.frontend
    ports:
      - "4200:4200"
    networks:
      - susfund

  db:
    container_name: susfund-db
    build:
      context: .
      dockerfile: Dockerfile.db
    ports:
     - "7777:3306"
    networks:
      - susfund

  wildfly:
    container_name: susfund-wildfly
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8080:8080"
      - "9990:9990"
    networks:
      - susfund
    depends_on:
      - db

networks:
  susfund:

Maven project structure:

susfund-backend
  --java 
     --org.andreasoo.susfund....

  --resources
     --META-INF
       --beans.xml
       --persistence.xml

After mvn clean install:

target
  --classes
  --maven-archiver
  --SusFund-1.0-SNAPSHOT
    --META-INF (empty)
    --WEB-INF
      --classes
         --META-INF
            --beans.xml
            --persistence.xml
         --org.andreasoo.susfund....

I'm not sure why there are two META-INF (och which one is empty) in the SusFund folder

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.andreasoo</groupId>
    <artifactId>SusFund</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>SusFund</name>
    <packaging>war</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.target>21</maven.compiler.target>
        <maven.compiler.source>21</maven.compiler.source>
        <junit.version>5.11.0</junit.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>jakarta.enterprise</groupId>
            <artifactId>jakarta.enterprise.cdi-api</artifactId>
            <version>4.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.ejb</groupId>
            <artifactId>jakarta.ejb-api</artifactId>
            <version>4.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.32</version>
        </dependency>
        <dependency>
            <groupId>jakarta.persistence</groupId>
            <artifactId>jakarta.persistence-api</artifactId>
            <version>3.2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
            <version>4.0.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <version>6.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>susfund-backend/main/java</directory>
            </resource>
            <resource>
                <directory>susfund-backend/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.4.0</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

UPDATED WITH ERROR LOGS AFTER CHANGING PORT TO 3306 IN SCRIPT

<snip>
18:14:02,508 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (ServerService Thread Pool -- 78) jakarta.resource.ResourceException: IJ000453: Unable to get managed connection for java:/jdbc/MySQLDataSource
<snip>


The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
        at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
        at com.mysql@9.2.0//com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:52)
        at com.mysql@9.2.0//com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:95)
        at com.mysql@9.2.0//com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:140)
        at com.mysql@9.2.0//com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:156)
        at com.mysql@9.2.0//com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:79)
        at com.mysql@9.2.0//com.mysql.cj.NativeSession.connect(NativeSession.java:142)
        at com.mysql@9.2.0//com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:961)
        at com.mysql@9.2.0//com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:825)
        ... 56 more
Caused by: java.net.ConnectException: Connection refused
        at java.base/sun.nio.ch.Net.connect0(Native Method)
        at java.base/sun.nio.ch.Net.connect(Net.java:589)
        at java.base/sun.nio.ch.Net.connect(Net.java:578)
        at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:583)
        at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
        at java.base/java.net.Socket.connect(Socket.java:751)
        at com.mysql@9.2.0//com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:144)
        at com.mysql@9.2.0//com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:53)
        ... 59 more

18:14:02,511 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 78) MSC000001: Failed to start service jboss.persistenceunit."SusFund-1.0-SNAPSHOT.war#myUnit".__FIRST_PHASE__: org.jboss.msc.service.StartException in service jboss.persistenceunit."SusFund-1.0-SNAPSHOT.war#myUnit".__FIRST_PHASE__: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] due to: Unable to determine Dialect without JDBC metadata (please set 'jakarta.persistence.jdbc.url' for common cases or 'hibernate.dialect' when a custom Dialect implementation must be provided)
        at org.jboss.as.jpa@36.0.0.Final//org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:113)
        at org.jboss.as.jpa@36.0.0.Final//org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:89)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
        at org.wildfly.security.elytron-base@2.6.2.Final//org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:664)
        at org.jboss.as.jpa@36.0.0.Final//org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1.run(PhaseOnePersistenceUnitServiceImpl.java:122)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
        at java.base/java.lang.Thread.run(Thread.java:1583)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] due to: Unable to determine Dialect without JDBC metadata (please set 'jakarta.persistence.jdbc.url' for common cases or 'hibernate.dialect' when a custom Dialect implementation must be provided)
        at org.hibernate@6.6.7.Final//org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:276)
        at org.hibernate@6.6.7.Final//org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:238)
        at org.hibernate@6.6.7.Final//org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215)
        at org.hibernate@6.6.7.Final//org.hibernate.service.ServiceRegistry.requireService(ServiceRegistry.java:68)
        at org.hibernate@6.6.7.Final//org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:52)
        at org.hibernate@6.6.7.Final//org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:136)
        at org.hibernate@6.6.7.Final//org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:247)
        at org.hibernate@6.6.7.Final//org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215)
        at org.hibernate@6.6.7.Final//org.hibernate.service.ServiceRegistry.requireService(ServiceRegistry.java:68)
        at org.hibernate@6.6.7.Final//org.hibernate.boot.internal.MetadataBuilderImpl.resolveWrapperArrayHandling(MetadataBuilderImpl.java:1024)
        at org.hibernate@6.6.7.Final//org.hibernate.boot.internal.MetadataBuilderImpl$MetadataBuildingOptionsImpl.<init>(MetadataBuilderImpl.java:629)
        at org.hibernate@6.6.7.Final//org.hibernate.boot.internal.MetadataBuilderImpl.<init>(MetadataBuilderImpl.java:139)
        at org.hibernate@6.6.7.Final//org.hibernate.boot.MetadataSources.getMetadataBuilder(MetadataSources.java:164)
        at org.hibernate@6.6.7.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:278)
        at org.hibernate@6.6.7.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:199)
        at org.hibernate@6.6.7.Final//org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:35)
        at org.hibernate@6.6.7.Final//org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:102)
        at org.hibernate.jipijapa-hibernate@36.0.0.Final//org.jboss.as.jpa.hibernate.TwoPhaseBootstrapImpl.<init>(TwoPhaseBootstrapImpl.java:27)
        at org.hibernate.jipijapa-hibernate@36.0.0.Final//org.jboss.as.jpa.hibernate.HibernatePersistenceProviderAdaptor.getBootstrap(HibernatePersistenceProviderAdaptor.java:220)
        at org.jboss.as.jpa@36.0.0.Final//org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl.createContainerEntityManagerFactoryBuilder(PhaseOnePersistenceUnitServiceImpl.java:239)
        at org.jboss.as.jpa@36.0.0.Final//org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:110)
        ... 10 more
Caused by: org.hibernate.HibernateException: Unable to determine Dialect without JDBC metadata (please set 'jakarta.persistence.jdbc.url' for common cases or 'hibernate.dialect' when a custom Dialect implementation must be provided)
        at org.hibernate@6.6.7.Final//org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:191)
        at org.hibernate@6.6.7.Final//org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:87)
        at org.hibernate@6.6.7.Final//org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.getJdbcEnvironmentWithDefaults(JdbcEnvironmentInitiator.java:181)
        at org.hibernate@6.6.7.Final//org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.getJdbcEnvironmentUsingJdbcMetadata(JdbcEnvironmentInitiator.java:392)
        at org.hibernate@6.6.7.Final//org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:129)
        at org.hibernate@6.6.7.Final//org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:81)
        at org.hibernate@6.6.7.Final//org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:130)
        at org.hibernate@6.6.7.Final//org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
        ... 30 more

18:14:02,515 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "SusFund-1.0-SNAPSHOT.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"SusFund-1.0-SNAPSHOT.war#myUnit\".__FIRST_PHASE__" => "org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] due to: Unable to determine Dialect without JDBC metadata (please set 'jakarta.persistence.jdbc.url' for common cases or 'hibernate.dialect' when a custom Dialect implementation must be provided)
    Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] due to: Unable to determine Dialect without JDBC metadata (please set 'jakarta.persistence.jdbc.url' for common cases or 'hibernate.dialect' when a custom Dialect implementation must be provided)
    Caused by: org.hibernate.HibernateException: Unable to determine Dialect without JDBC metadata (please set 'jakarta.persistence.jdbc.url' for common cases or 'hibernate.dialect' when a custom Dialect implementation must be provided)"}}
18:14:02,644 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 45) WFLYSRV0010: Deployed "SusFund-1.0-SNAPSHOT.war" (runtime-name : "SusFund-1.0-SNAPSHOT.war")
18:14:02,649 INFO  [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0186:   Services which failed to start:      service jboss.persistenceunit."SusFund-1.0-SNAPSHOT.war#myUnit".__FIRST_PHASE__: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] due to: Unable to determine Dialect without JDBC metadata (please set 'jakarta.persistence.jdbc.url' for common cases or 'hibernate.dialect' when a custom Dialect implementation must be provided)

After copying .war file to .war.dodeploy in /deployments the server logs say this:

18:16:22,997 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) WFLYJCA0019: Stopped Driver service with driver-name = SusFund-1.0-SNAPSHOT.war_com.mysql.cj.jdbc.Driver_8_0
18:16:23,026 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 26) Stopped hibernate cache container
18:16:23,028 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0028: Stopped deployment SusFund-1.0-SNAPSHOT.war (runtime-name: SusFund-1.0-SNAPSHOT.war) in 33ms
18:16:23,033 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "SusFund-1.0-SNAPSHOT.war" (runtime-name: "SusFund-1.0-SNAPSHOT.war")
18:16:23,600 INFO  [org.jboss.as.jpa] (MSC service thread 1-3) WFLYJPA0002: Read persistence.xml for myUnit
18:16:23,632 INFO  [org.jipijapa] (MSC service thread 1-4) JIPIORMV6020260: Second level cache enabled for SusFund-1.0-SNAPSHOT.war#myUnit
18:16:23,636 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) WFLYWELD0003: Processing weld deployment SusFund-1.0-SNAPSHOT.war
18:16:23,653 INFO  [org.infinispan.CONTAINER] (ServerService Thread Pool -- 26) ISPN000556: Starting user marshaller 'org.wildfly.clustering.cache.infinispan.marshalling.UserMarshaller'
18:16:23,707 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 26) Started hibernate cache container
18:16:23,713 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 26) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'SusFund-1.0-SNAPSHOT.war#myUnit'
18:16:23,714 INFO  [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 26) HHH000204: Processing PersistenceUnitInfo [name: myUnit]
18:16:23,754 INFO  [org.jipijapa] (MSC service thread 1-3) JIPIORMV6020260: Second level cache enabled for SusFund-1.0-SNAPSHOT.war#myUnit
18:16:23,783 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.cj.jdbc.Driver (version 8.0)
18:16:23,846 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) WFLYJCA0018: Started Driver service with driver-name = SusFund-1.0-SNAPSHOT.war_com.mysql.cj.jdbc.Driver_8_0
18:16:24,122 INFO  [org.hibernate.orm.connections.pooling] (ServerService Thread Pool -- 26) HHH10001005: Database info:
        Database JDBC URL [Connecting through datasource 'org.jboss.as.connector.subsystems.datasources.WildFlyDataSource@6c65ccee']
        Database driver: undefined/unknown
        Database version: 9.2
        Autocommit mode: undefined/unknown
        Isolation level: undefined/unknown
        Minimum pool size: undefined/unknown
        Maximum pool size: undefined/unknown
18:16:24,131 INFO  [org.hibernate.cache.internal.RegionFactoryInitiator] (ServerService Thread Pool -- 26) HHH000025: Second-level cache region factory [org.infinispan.hibernate.cache.v62.InfinispanRegionFactory]
18:16:24,226 INFO  [org.hibernate.envers.boot.internal.EnversServiceImpl] (ServerService Thread Pool -- 26) Envers integration enabled? : true
18:16:24,458 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 26) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'SusFund-1.0-SNAPSHOT.war#myUnit'
18:16:25,486 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 83) WFLYUT0021: Registered web context: '/SusFund-1.0-SNAPSHOT' for server 'default-server'
18:16:25,544 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) WFLYSRV0016: Replaced deployment "SusFund-1.0-SNAPSHOT.war" with deployment "SusFund-1.0-SNAPSHOT.war"
18:16:25,545 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) WFLYCTL0183: Service status report
WFLYCTL0185:    Newly corrected services:
      service jboss.deployment.unit."SusFund-1.0-SNAPSHOT.war".WeldStartService (new available)
      service jboss.deployment.unit."SusFund-1.0-SNAPSHOT.war".component."jakarta.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START (new available)
      service jboss.deployment.unit."SusFund-1.0-SNAPSHOT.war".component."jakarta.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".WeldInstantiator (new available)
      service jboss.deployment.unit."SusFund-1.0-SNAPSHOT.war".component."jakarta.servlet.jsp.jstl.tlv.ScriptFreeTLV".START (new available)
      service jboss.deployment.unit."SusFund-1.0-SNAPSHOT.war".component."jakarta.servlet.jsp.jstl.tlv.ScriptFreeTLV".WeldInstantiator (new available)
      service jboss.deployment.unit."SusFund-1.0-SNAPSHOT.war".component."org.jboss.weld.module.web.servlet.WeldInitialListener".START (new available)
      service jboss.deployment.unit."SusFund-1.0-SNAPSHOT.war".component."org.jboss.weld.module.web.servlet.WeldInitialListener".WeldInstantiator (new available)
      service jboss.deployment.unit."SusFund-1.0-SNAPSHOT.war".component."org.jboss.weld.module.web.servlet.WeldTerminalListener".START (new available)
      service jboss.deployment.unit."SusFund-1.0-SNAPSHOT.war".component."org.jboss.weld.module.web.servlet.WeldTerminalListener".WeldInstantiator (new available)
      service jboss.deployment.unit."SusFund-1.0-SNAPSHOT.war".deploymentCompleteService (new available)
      service jboss.deployment.unit."SusFund-1.0-SNAPSHOT.war".ee.ComponentRegistry (new available)
      service jboss.deployment.unit."SusFund-1.0-SNAPSHOT.war".undertow-deployment (new available)
      service jboss.deployment.unit."SusFund-1.0-SNAPSHOT.war".undertow-deployment.UndertowDeploymentInfoService (new available)
      service jboss.deployment.unit."SusFund-1.0-SNAPSHOT.war".weld.weldClassIntrospector (new available)
      service jboss.persistenceunit."SusFund-1.0-SNAPSHOT.war#myUnit" (new available)

The above logs make it seem like the war files have been deployed successfully. And they even say war.deployed in the deployments folder. But when I try to access endpoints from localhost:8080 from dockerhost it gives me 404 response.


Solution

  • Found the solution to Connection issues and 404

    The database didn't have time too boot up before my wildfly container started to attempt establish connection. I still got 404 responses from the endpoints but that was due to the maven plugin conflicting with my folder setup and specific build resources in the pom.xml.

    I had to add health checks in the db and depends on service_healthy condition in wildfly. As follows:

    services:
      susfund-fe:
        container_name: susfund-fe
        build:
          context: .
          dockerfile: Dockerfile.frontend
        ports:
          - "4200:4200"
        networks:
          - susfund
    
      db:
        container_name: susfund-db
        build:
          context: .
          dockerfile: Dockerfile.db
        ports:
         - "7777:3306"
        networks:
          - susfund
        healthcheck:
          test: [ "CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-ptest1234" ]
          interval: 5s
          timeout: 5s
          retries: 100
    
      wildfly:
        container_name: susfund-wildfly
        build:
          context: .
          dockerfile: Dockerfile
        ports:
          - "8080:8080"
          - "9990:9990"
        networks:
          - susfund
        depends_on:
           db:
            condition: service_healthy
    
    networks:
      susfund: