How to ensure JNDI resources are available for application during startup/shutdown of JBoss EAP 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?

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 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
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.