Reputation: 66637
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?
Upvotes: 1
Views: 2475
Reputation: 8467
Looks like when you stop
the server and run the standalone1
,
the server isnt stopped rather in transition
because of which it does get the initialContext
but fails later on when the server transition is complete.
So a question : How are you stopping the server? Killing the process or some command line script to stop? using eclipse ? or what?
When you stop the server use netstat -a
for windows dos to see what all ports are being listened on. Could be a possibility that the Jboss port is still listening. Confirm that the port is not being listened on and then run your standalone, you should get error on the InitialContext
the bottom line I am trying to make is the case 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.
Is not a valid case and should not happen.
Upvotes: 1
Reputation: 310936
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?
Upvotes: 3