Search code examples
javajakarta-eejndijboss7.xjava-7

IntialContext instantiation failing


I wrote a plain simple java program to perform remote connection with HornetQ server.

Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
p.put(Context.PROVIDER_URL, "remote://myIP:4447");
p.put(Context.SECURITY_PRINCIPAL, "user");
p.put(Context.SECURITY_CREDENTIALS, "pwd");

final InitialContext iniCtx = new InitialContext(p);

If JBoss server is down, final InitialContext iniCtx = new InitialContext(p); statements itself throwing

javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: Operation failed with status WAITING]

Is this valid case, Instantiating InitialContext itself should fail if JBoss server (or any other application server) is down?

If this is valid case,

I have another standalone app (this is not on any server, standalone java application)

Inside this standalone app, I am trying to create IntialContext exact same lines as above.

When JBoss server is down, InitialContext instantiation is not failing.

Totally confused on how this IntialContext works, any input would be appreciated.

Update:

Are there any jars are something which may effect InitialContext behavior?


Solution

  • Is this valid case, Instantiating InitialContext itself should fail if JBoss server (or any other application server) is down?

    Yes.

    If this is valid case, I have another standalone app (this is not on any server, standalone java application). Inside this standalone app, I am trying to create IntialContext exact same lines as above. When JBoss server is down, InitialContext instantiation is not failing.

    Really. Hard to believe. What is it doing instead? How do you know the server is down if it doesn't fail?