In a customer's environment, updates are scheduled to run on several servers at nighttime, each time this happens our WildFly application is not recovering until I reboot the application server itself because the database connection couldn't be established when initialising the PersistenceUnit during boot (standalone-full.xml, installed as Windows Service):
[Exception for the database connection omitted, it's basically really not up at this time]
2024-03-26 01:51:00,009 INFO [org.jboss.as.server] (ServerService Thread Pool -- 46) WFLYSRV0010: Deployed "no.war" (runtime-name : "no.war")
2024-03-26 01:51:00,013 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service jboss.persistenceunit."no.war#xxxPU": jakarta.persistence.PersistenceException: [PersistenceUnit: xxxPU] Unable to build Hibernate SessionFactory
WFLYCTL0448: 170 additional services are down due to their dependencies being missing or failed
The datasource definition:
<datasource jta="false" jndi-name="java:jboss/datasources/xxx" pool-name="xxx">
<connection-url>jdbc:sqlserver://xxx.xxx.de\INSTANCE;DatabaseName=xxx;encrypt=false</connection-url>
<driver>mssql</driver>
<security>
<user-name>CENSORED</user-name>
<password>CENSORED</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker"/>
</validation>
</datasource>
Whereas the persistence.xml looks as follows:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="xxxPU">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:jboss/datasources/xxx</jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
<property name="hibernate.jdbc.time_zone" value="Europe/Berlin"/>
</properties>
</persistence-unit>
</persistence>
While I can understand that it might be a desired outcome, I personally don't want the server to remain in this failed state until restart. Is there any sensible way to configure WildFly to retry the deployment periodically if the start of any subsystem has failed?