EAP 7.4 JNDI lookup of 'java:module' namespace fails with NameNotFoundException from AsyncContext

Solution Verified - Updated -

Issue

JNDI lookup of 'java:module' namespace fails with NameNotFoundException from AsyncContext.
Example, consider there's a servlet like this:

@WebServlet(urlPatterns = "/async-module", asyncSupported = true) <---- async
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", //<--------------- 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 { //<--- Processing class

    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);
        }
    }
}

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7.4

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content