Is there a pattern to make sure, that a java ee application deploys, even if the datasource is faulty? My application does not start if the datasource can not be reached. The entity manager can not be initialized and therefor can not be injected in my ejb. This fails the entire deployment.
The application does have a DLQ for when the datasource can not be reached.
Example:
persistance.xml
<persistence-unit name="dataSourceExample" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/dataSourceExample</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.generate_statistics" value="false"/>
</properties>
</persistence-unit>
datasource config in wildfly
<datasource jndi-name="java:jboss/datasources/dataSourceExample" pool-name="dataSourceExamplePool" use-ccm="false">
<connection-url>someurl</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<driver>com.oracle.ojdbc</driver>
<pool>
<max-pool-size>25</max-pool-size>
</pool>
<security>
<user-name>someusername</user-name>
<password>somepassword</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
<stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
</validation>
<timeout>
<blocking-timeout-millis>5000</blocking-timeout-millis>
</timeout>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
Injected entity manager in ejb
@PersistenceContext(unitName = "dataSourceExample")
private EntityManager dataSourceExampleEm;
I just want the application to be deployed, even if it is not fully functional. It will work later, when the datasource "returns".