[jboss-jira] [JBoss JIRA] (AS7-5746) Webapp's ENC destroyed before ServletContextListener invoked
Eduardo Martins (JIRA)
jira-events at lists.jboss.org
Wed Dec 5 07:21:21 EST 2012
[ https://issues.jboss.org/browse/AS7-5746?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12739589#comment-12739589 ]
Eduardo Martins commented on AS7-5746:
--------------------------------------
Hello Josef, the commit updated the weld subsystem too, so can you please detail on how compatibility is broken?
IIRC such change was promoted due to unit testing, see naming/src/test/java/org/jboss/as/naming/WritableServiceBasedNamingStoreTestCase.java @ https://github.com/emmartins/jboss-as/commit/63ae76b354a866f96a0c0de3d38a449fa8b31c54
> Webapp's ENC destroyed before ServletContextListener invoked
> ------------------------------------------------------------
>
> Key: AS7-5746
> URL: https://issues.jboss.org/browse/AS7-5746
> Project: Application Server 7
> Issue Type: Bug
> Components: Naming, Web
> Affects Versions: 7.1.1.Final
> Reporter: Philippe Marschall
> Assignee: Eduardo Martins
> Fix For: 7.2.0.Alpha1, 7.1.4.Final (EAP)
>
>
> It looks as if when {{javax.servlet.ServletContextListener#contextDestroyed(ServletContextEvent)}} is invoked the naming service / context has already been shut down.
> Consider the following class
> {code}
> public class BindingListener implements ServletContextListener {
>
> private static final Logger LOG = Logger.getLogger("binding-listener");
> private static final String NAME = "java:global/env/foo";
> private static final String VALUE = "FOO";
> @Override
> public void contextInitialized(ServletContextEvent sce) {
> LOG.info("contextInitialized");
> try {
> Context context = new InitialContext();
> context.rebind(NAME, VALUE);
> } catch (NamingException e) {
> LOG.log(Level.SEVERE, "could not bind value", e);
> }
>
> }
> @Override
> public void contextDestroyed(ServletContextEvent sce) {
> LOG.info("contextDestroyed");
> try {
> Context context = new InitialContext();
> context.unbind(NAME);
> } catch (NamingException e) {
> LOG.log(Level.SEVERE, "could not unbind value", e);
> }
> }
> }
> {code}
> This results in the following exception when shutting down the container.
> {code}
> 00:50:51,171 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/context-listener-0.1.0-SNAPSHOT]] (MSC service thread 1-3) JBWEB000306: Exception sending context destroyed event to listener instance of class com.github.marschall.BindingListener: java.lang.IllegalArgumentException: JBAS011857: NamingStore is null
> at org.jboss.as.naming.NamingContext.<init>(NamingContext.java:151)
> at org.jboss.as.naming.NamingContext.<init>(NamingContext.java:124)
> at org.jboss.as.naming.InitialContext.<init>(InitialContext.java:86)
> at org.jboss.as.naming.InitialContextFactory.getInitialContext(InitialContextFactory.java:44)
> at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684) [rt.jar:1.8.0-ea]
> at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:311) [rt.jar:1.8.0-ea]
> at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:339) [rt.jar:1.8.0-ea]
> at javax.naming.InitialContext.unbind(InitialContext.java:439) [rt.jar:1.8.0-ea]
> at com.github.marschall.BindingListener.contextDestroyed(BindingListener.java:41) [classes:]
> at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3419) [jbossweb-7.2.0.Alpha2.jar:7.2.0.Alpha2]
> at org.apache.catalina.core.StandardContext.stop(StandardContext.java:3912) [jbossweb-7.2.0.Alpha2.jar:7.2.0.Alpha2]
> at org.jboss.as.web.deployment.WebDeploymentService.stop(WebDeploymentService.java:118) [jboss-as-web-7.2.0.Alpha1-SNAPSHOT.jar:7.2.0.Alpha1-SNAPSHOT]
> at org.jboss.msc.service.ServiceControllerImpl$StopTask.stopService(ServiceControllerImpl.java:1911)
> at org.jboss.msc.service.ServiceControllerImpl$StopTask.run(ServiceControllerImpl.java:1874)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.8.0-ea]
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.8.0-ea]
> at java.lang.Thread.run(Thread.java:722) [rt.jar:1.8.0-ea]
> {code}
> This seems to be a reappearance of JBAS-672.
> See also this Stackoverflow thread
> http://stackoverflow.com/questions/12497538/jndi-lookup-in-servletcontextlistener-contextdestroyed
> I would provide a patch/pull request if somebody can point me in the right direction.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list