Hey foks
So i am trying to make my application robust to database failures and errors. To this end i am trying to start my application without a running database, but the deployment errors out with:
WARN [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (ServerService Thread Pool -- 14) IJ000604: Throwable while attempting to get a new connection: null: javax.resource.ResourceException: IJ031084: Unable to create connection
WARN [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator] (ServerService Thread Pool -- 14) HHH000342: Could not obtain connection to query metadata : javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources...
ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 14) MSC000001: Failed to start service jboss.persistenceunit..... org.jboss.msc.service.StartException in service jboss.persistenceunit....: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
I can start the application when the database is running.
I am trying to follow
The twelve-factor app methodology as a guideline to the application I am building, and in this instance i need to be able to start my application regardless of the status of the database. Furthermore should the database become unavailable the application should keep running and if the database becomes available again then the application should function without intervention needed.
Of course this requires error handling in the application code, but how do i configure thorntail to allow this behavior? and avoid the deployment crashing in the first place?
myds is defined via enviroment variables:
THORNTAIL_DATASOURCES_DATA_DASH_SOURCES_MYDS_DRIVER_DASH_NAME: postgresql
THORNTAIL_DATASOURCES_DATA_DASH_SOURCES_MYDS_CONNECTION_DASH_URL: jdbc:postgresql://database:5432/postgres
THORNTAIL_DATASOURCES_DATA_DASH_SOURCES_MYDS_USER_DASH_NAME: postgres
THORNTAIL_DATASOURCES_DATA_DASH_SOURCES_MYDS_PASSWORD: postgres
The persistance.xml
The way i am currently accessing the database from code looks like this:
import javax.persistence.PersistenceContext;
import javax.persistence.EntityManager;
@PersistenceContext(unitName = "myPU")
EntityManager em;
Also i'm using Thorntail 2.6.0.FINAL
Thanks