-
Bug
-
Resolution: Done
-
Major
-
JBossAS-3.2.6 Final
-
None
SourceForge Submitter: bstansberry .
For a webapp I wrote a ServletContextListener that
attempts to access an EJB when it's contextDestroyed()
method is invoked. The call fails because the
EmbeddedTomcatService's performUndeploy() method is
unbinding the webapp's ENC before the listener gets
invoked.
From what I read in the Servlet 2.3 spec and the
ServletContextListener JavaDoc, contextDestroyed() is
meant to be called, despite the past tense name,
when "the servlet context is about to be shut down",
not after it's shut down.
Actually, from looking at the
EmbeddedTomcatService.performUndeploy() code, it
looks like the ENC will be gone before any servlet's
destroy() method is invoked. The spec and the JavaDoc
state that one of the purposes of destroy() is to allow a
servlet to save any persistent state, so it would seem
logical that the servlet should still have access to its
ENC when destroy() is called.
I'm going to start preparing and testing a patch for this,
but if any of the gurus out there disagree with my
interpretation of the spec, please let me know.
Here's a stack trace. (Please note that
c.w.jboss.tomcat.tc4.SingleSignOnTomcatService
reference in the trace is 99.9% identical to
o.j.web.tomcat.tc4.EmbeddedTomcatService; the
differences don't impact this case)
[19:03:21,507,ResourceTreeLoader] Intranet/ROOT:
javax.naming.NameNotFoundException thrown during
menu link clearing
javax.naming.NameNotFoundException: env not
bound at org.jnp.server.NamingServer.getBinding
(NamingServer.java:495) at
org.jnp.server.NamingServer.getBinding
(NamingServer.java:503) at
org.jnp.server.NamingServer.getObject
(NamingServer.java:509) at
org.jnp.server.NamingServer.lookup
(NamingServer.java:253) at
org.jnp.interfaces.NamingContext.lookup
(NamingContext.java:528) at
org.jnp.interfaces.NamingContext.lookup
(NamingContext.java:642) at
org.jnp.interfaces.NamingContext.lookup
(NamingContext.java:507) at
javax.naming.InitialContext.lookup
(InitialContext.java:347) at
com.wanconcepts.j2ee.util.NamingDelegate.lookup
(NamingDelegate.java:71) at
com.wanconcepts.j2ee.util.NamingDelegate.getEJBHome
(NamingDelegate.java:54) at
com.wanconcepts.j2ee.util.LocalRemoteHelper.getHome
(LocalRemoteHelper.java:266) at
com.wanconcepts.wcss.ejb.menu.ResourceTreeHelper.ge
tResourceTreeFacade(ResourceTreeHelper.java:250) at
com.wanconcepts.wcss.ejb.menu.ResourceTreeHelper.cle
arMenuLinkChildren(ResourceTreeHelper.java:225) at
com.wanconcepts.xnet.listener.ResourceTreeLoader.cont
extDestroyed(ResourceTreeLoader.java:142) at
org.apache.catalina.core.StandardContext.listenerStop
(StandardContext.java:3310) at
org.apache.catalina.core.StandardContext.stop
(StandardContext.java:3663) at
org.apache.catalina.core.ContainerBase.removeChild
(ContainerBase.java:1036) at
org.apache.catalina.core.StandardHostDeployer.remove
(StandardHostDeployer.java:470) at
org.apache.catalina.core.StandardHost.remove
(StandardHost.java:852) at
com.wanconcepts.jboss.tomcat.tc4.SingleSignOnTomcat
Service.performUndeploy
(SingleSignOnTomcatService.java:346) at
org.jboss.web.AbstractWebContainer.stop
(AbstractWebContainer.java:476) at
org.jboss.deployment.MainDeployer.stop
(MainDeployer.java:489) at
org.jboss.deployment.MainDeployer.stop
(MainDeployer.java:504) at
org.jboss.deployment.MainDeployer.undeploy
(MainDeployer.java:472) at
org.jboss.deployment.MainDeployer.shutdown
(MainDeployer.java:359) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39) at
sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25) at
java.lang.reflect.Method.invoke(Method.java:324) at
org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke
(ReflectedMBeanDispatcher.java:284) at
org.jboss.mx.server.MBeanServerImpl.invoke
(MBeanServerImpl.java:546) at
org.jboss.system.server.ServerImpl$ShutdownHook.shutd
ownDeployments(ServerImpl.java:849) at
org.jboss.system.server.ServerImpl$ShutdownHook.shutd
own(ServerImpl.java:824) at
org.jboss.system.server.ServerImpl$ShutdownHook.run
(ServerImpl.java:812)