javax.naming.NamingException: Unable to invoke lookup, status=WAITING

Solution Verified - Updated -

Environment

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

Issue

  • User is using web application with Struts and HornetQ configured. This issue occurs from execute() of the Action class. While JNDI lookup for the connection factory user gets the below exception :
3-Feb-2015 16:18:54.125 EST - ERROR  a.b.webapp.action.TestAction - Exception Occured: Exception: Unable to invoke lookup, status=WAITING
javax.naming.NamingException: Unable to invoke lookup, status=WAITING
                at org.jboss.naming.remote.protocol.v1.Protocol$1.execute(Protocol.java:98)
                at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1.lookup(RemoteNamingStoreV1.java:95)
                at org.jboss.naming.remote.client.HaRemoteNamingStore$1.operation(HaRemoteNamingStore.java:275)
                at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:132)
                at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:271)
                at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79)
                at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83)
                at javax.naming.InitialContext.lookup(InitialContext.java:411)
                at javax.naming.InitialContext.lookup(InitialContext.java:411)
                at a.b..webapp.util.TestMessage.testJMSConnection(TestMessage.java:63)
                at a.b..webapp.util.TestMessage.<init>(TestMessage.java:34)
                at a.b..webapp.util.TestMessage.getInstance(TestMessage.java:42)
                at a.b..webapp.action.TestAction.execute(TestAction.java:700)
                at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:480)
                at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
                at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1420)
                at a.b.webapp.framework.struts.TestActionServlet.process(TestActionServlet.java:103)
                at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:520)
                at a.b..webapp.controller.TestController.doPost(TestController.java:72)

Resolution

If on JBoss EAP 6.2, Apply JBoss EAP 6.2 CP4.

  • There are couple of scenarios might have occurred:
    • User have configured queue details in JBoss Box but trying to access locally.
    • User have configured queue details in JBoss Box but trying to access remotely.

The root cause of the issue :

  • Normally the exception will occur if server is not reachable from the BOX where client is running.

  • User might be unable to reach that host address due to network failure or firewall restriction available at network layer which is restricting HostName access on port 9999.

Scenario when user will get this exception :

  • Scenario-1 : If user is running server to listen on localhost but from client side user might be trying to connect to the server using the IP-Address or vice versa.

  • Scenario-2 : User might have changed the default remoting port 4447 of the server or the port might be blocked.

Below are the possible solutions are :

  • By default the JBoss Management Interface address is localhost, so please make sure that user is starting their JBoss using the following option:
./standalone.sh   -b<yourHostName\>  -bmanagement <yourHostName\>

OR

./standalone.sh   -Djboss.bind.address=<yourHostName\>   -Djboss.bind.address.management=<yourHostName\>
  • Also it would be best to check that there is no firewall restriction available at network layer which is restricting yourHostName access on port 9999.

  • Maybe user is using a port-offset on the server, so instead of port 4447 user should use 4447 + offset.

  • JBoss provides a single Jar which can be used by the client like /jboss-eap-6.3/bin/client/jboss-client.jar so just try removing all the other jars from the class-path and just have this.

Root Cause

There was an issue fixed in 6.2 CP2 and later, to have the underlying cause included in the naming exception:
(6.3.0) Remote Naming throws the same exception for different causes
(6.2.x) Remote Naming throws the same exception for different causes

If the host or port details are incorrect, the following +CommunicationException+ will be thrown, indicating the connection timed-out:

javax.naming.CommunicationException: Failed to connect to
any server. Servers tried: [remote://localhost:4447 (Operation failed
with status WAITING after 5000 MILLISECONDS), remote://localhost2:4321
(Operation failed with status WAITING after 5000 MILLISECONDS)] [Root
exception is java.net.ConnectException: Operation failed with status
WAITING after 5000 MILLISECONDS]

If one of the available servers responds, but the subsequent authentication fails, the following +AuthenticationException+ will be thrown:

javax.naming.AuthenticationException: Failed to connect to
any server. Servers tried: [remote://localhost:4447 (Authentication
failed: all available authentication mechanisms failed),
remote://localhost2:4321 (Operation failed with status WAITING after
5000 MILLISECONDS)] [Root exception is
javax.security.sasl.SaslException: Authentication failed: all available
authentication mechanisms failed]

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments