java - Glassfish: Silently ignore unavailable data source at application start up -
i have ejb application uses jpa 2.0 on glassfish 3.1.2 (provider eclipselink). when database down application not start , more: can't deployed. because eclipselink initial verification.
is there way application can deloyed , started if database down?
background: resource being unavailable comes not play until first business function called accesses database. application startup till first business function call there time window database may started.
changing defaults in glassfish-resources.xml
attributes connection-creation-retry-attempts
, connection-creation-retry-interval-in-seconds
of <jdbc-connection-pool>
helps in way still check database availabilty @ startup not @ first use.
exceptionhandler
eclipselink not way have in mind: when exception handler comes play eclipselink has started verification process , hence has tried connect database. way looking postpone verfification process until first business call.
eclipselink database verification is performed @ first use. however, first use @persistanceunit
injection point handled container. @persistanceunit
injection handled @ deployment time, , there's nothing can catch that. if don't want eclipselink verify @ deployment time, you'll need handle own entitymanagerfactory
.
i'd recommend creating application context listener, can hold copy of entitymanagerfactory
, , perform tear down when undeploy/redeploy. during normal run can not set until needed. here's basic model follow: https://en.wikipedia.org/wiki/initialization-on-demand_holder_idiom
Comments
Post a Comment