I want to release some resources when my application stops (undeploy or server instance shutdown). The resources are located in jndi.
Currently I'm using ServletContextListener interface: on contextInitialized I bind resources to JNDI and on contextDestroyed I have to release the resources, but I have an exception:
Error looking up myName, service service jboss.naming.context.java.myName is not started
I tryed to bind data on different addresses (java:comp/myName, java:comp/env/myName, java:/myName,java:jboss/myName), but behaviour is the same in all cases.
When the application runs I can successfuly look up my object.
What I'm doing wrong? My be there is another method to release resources on application stop?
P.S. I also attached a sample project: if deploy it and then undeploy you can see that it can't look up the objects on destroy. In index.jsp you can see that it's possible to lookup the objects when the app runs.