I'm trying to handle database connection exceptions more gracefully than what seems to happen by default. Currently, if there is anything wrong with the database, or the properties used in defining the DataSource/EntityManagerFactory, the application server (tomcat) will fail to start. Ideally I'd like to catch any exception that occurs when setting up these beans, and fail in a way that allows the application server to finish loading.
A basic example of what I'm trying to test right now is an invalid port for an SQL Express Server. Obviously the solution to that problem is to get the port correct and restart.
In case someone is wondering why I need to worry about failed connections: it is to help provide some better feedback in the field if things get installed and configured wrong. I'd rather be able to return some useful error status through a restful endpoint than just having the entire app server fail to start.
A basic example of what I'm trying to test right now is an invalid port for an SQL Express Server. Obviously the solution to that problem is to get the port correct and restart.
In case someone is wondering why I need to worry about failed connections: it is to help provide some better feedback in the field if things get installed and configured wrong. I'd rather be able to return some useful error status through a restful endpoint than just having the entire app server fail to start.