Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-22735

[GSS](7.4.z) UNDERTOW-1989 - JNDI lookup of 'java:module' namespace fails with NameNotFoundException from AsyncContext

    XMLWordPrintable

Details

    • False
    • False
    • +
    • Hide
      1. build the project using Maven
        > mvn clean package
      2. install JBoss EAP 7.4 and set JBOSS_HOME
      3. deploy the application using deplyment dir or console/CLI:
        > cp my-application/target/my-app-1.0.1.war $JBOSS_HOME/standalone/deployments
      4. start the server in different shell
        > $JBOSS_HOME/bin/standalone.sh
      5. call the servlet to see 'java:module' isn't working:
        > curl http://localhost:8080/MyApp/async-module
        javax.naming.NameNotFoundException: java:module/ApplicationConfig!org.jboss.reproducer.ConfigInterface
        at org.jboss.as.naming.InitialContext$DefaultInitialContext.findContext(InitialContext.java:191)
        at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:235)
        at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)
        at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)
        at javax.naming.InitialContext.lookup(InitialContext.java:417)
        at javax.naming.InitialContext.lookup(InitialContext.java:417)
        at org.jboss.reproducer.Processing.lookup(Processing.java:49)
        at org.jboss.reproducer.Processing.run(Processing.java:26)
        at io.undertow.servlet.spec.ServletContextImpl.call(ServletContextImpl.java:181)
        at io.undertow.servlet.spec.ServletContextImpl.call(ServletContextImpl.java:178)
        at io.undertow.servlet.spec.ServletContextImpl.invokeRunnable(ServletContextImpl.java:1069)
        at io.undertow.servlet.spec.AsyncContextImpl.run(AsyncContextImpl.java:326)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1348)
        at org.xnio.XnioWorker$WorkerThreadFactory.run(XnioWorker.java:1280)
        at java.lang.Thread.run(Thread.java:748)
      6. call the servlet to see 'java:global' is working:
        > curl http://localhost:8080/MyApp/async-global
        lookup [java:global/my-app-1.0.1/ApplicationConfig] : aValueFromConfig
      Show
      build the project using Maven > mvn clean package install JBoss EAP 7.4 and set JBOSS_HOME deploy the application using deplyment dir or console/CLI: > cp my-application/target/my-app-1.0.1.war $JBOSS_HOME/standalone/deployments start the server in different shell > $JBOSS_HOME/bin/standalone.sh call the servlet to see 'java:module' isn't working: > curl http://localhost:8080/MyApp/async-module javax.naming.NameNotFoundException: java:module/ApplicationConfig!org.jboss.reproducer.ConfigInterface at org.jboss.as.naming.InitialContext$DefaultInitialContext.findContext(InitialContext.java:191) at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:235) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189) at javax.naming.InitialContext.lookup(InitialContext.java:417) at javax.naming.InitialContext.lookup(InitialContext.java:417) at org.jboss.reproducer.Processing.lookup(Processing.java:49) at org.jboss.reproducer.Processing.run(Processing.java:26) at io.undertow.servlet.spec.ServletContextImpl.call(ServletContextImpl.java:181) at io.undertow.servlet.spec.ServletContextImpl.call(ServletContextImpl.java:178) at io.undertow.servlet.spec.ServletContextImpl.invokeRunnable(ServletContextImpl.java:1069) at io.undertow.servlet.spec.AsyncContextImpl.run(AsyncContextImpl.java:326) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1348) at org.xnio.XnioWorker$WorkerThreadFactory.run(XnioWorker.java:1280) at java.lang.Thread.run(Thread.java:748) call the servlet to see 'java:global' is working: > curl http://localhost:8080/MyApp/async-global lookup [java:global/my-app-1.0.1/ApplicationConfig] : aValueFromConfig

    Description

      Consider there's a servlet like this:

      @WebServlet(urlPatterns = "/async-module", asyncSupported = true)
      public class AnAsyncServlet extends HttpServlet {
      
          @Override
          public final void doGet(final HttpServletRequest request, HttpServletResponse response)
                  throws ServerException, IOException {
              final AsyncContext asyncContext = request.startAsync();
              asyncContext.start(new Processing("java:module/ApplicationConfig!org.jboss.ConfigInterface",
                      (HttpServletResponse) asyncContext.getResponse()));
          }
      }
      

      and that Processing class is doing a JNDI lookup of the JNDI name in the java:module namespace as above, like:

      public class Processing implements Runnable {
      
          private final HttpServletResponse response;
          private final String jndi;
      
          public Processing(final String jndi, final HttpServletResponse response) {
              super();
              this.response = response;
              this.jndi = jndi;
          }
      
          @Override
          public void run() {
              String result;
              try {
                  result = ((ConfigInterface) new InitialContext().lookup(jndi)).getConfigValue();
      
                  response.setStatus(HttpServletResponse.SC_OK);
                  response.getWriter().write(result);
                  response.getWriter().flush();
                  response.getWriter().close();
              } catch (Exception e) {
                  throw new RuntimeException("Error", e);
              }
          }
      }
      

      As the AsyncContext should be container managed, the lookup of the java:module namespace should be possible.

      Attached you can find the reproducer.zip, it contains a README.txt that explains how to reproduce this issue.

      Attachments

        Issue Links

          Activity

            People

              rhn-support-rmartinc Ricardo Martin Camarero
              rhn-support-rmartinc Ricardo Martin Camarero
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: