How to ensure JNDI resources are available for application during startup/shutdown of JBoss EAP 7 / 6

Solution Verified - Updated -

Issue

  • An web application uses a javax.servlet.ServletContextListener to catch the contextDestroyed event and needs to access to a database. Attempts to obtain the DataSource from JNDI during this process receive a javax.naming.NameNotFoundException indicating that the JNDI repository does not contain the DataSource.

  • Is it possible to configure the datasource such that when the JBoss is shut down, then, first the application is disabled/undeployed and then the DataSource will be shutdown?

  • How do I ensure a resource in JNDI is available during startup or shutdown of an application?

  • I have a HA singleton service(cluster wide) that initializes an ejb timer. To initialize the timer, I am doing a jndi look up of the ejb from HA service. This look up is randomly failing with 'Caused by: javax.naming.NameNotFoundException.

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7.x
    • 6.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In