Jboss 5.1.0.GA fails to shutdown with 'Could not obtain connection to any of these urls:'
johnnyjboss Jan 20, 2010 12:22 PMI recently attempted a stock install of Jboss 5.1.0.GA and experieced a failure to shutdown with the following error:
Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost/127.0.0.1:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost/127.0.0.1:1099 [Root exception is java.net.ConnectException: Connection refused]]]
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1763)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:693)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.jboss.Shutdown.main(Shutdown.java:219)
[stack trace truncated for the sake of brevity]
The issue is not classpath related as others have had in relation to ClassNotFound errors on shutdown.
It was clear there was a connection issue to the jnp port on 1099. I checked netstat -an and saw the following:
jboss_user@server_name:/opt/jboss/jboss-5.1.0.GA/bin% netstat -an | grep 1099
tcp 0 0 192.168.1.24:1099 0.0.0.0:* LISTEN
I also confirmed using lsof:
jboss_user@server_name:/opt/jboss/jboss-5.1.0.GA/bin% lsof -i:1099
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
java 18738 jboss_user 175u IPv4 40278677 TCP server_name.company.com:rmiregistry (LISTEN)
Since it was clear that my jboss process was listening on port 1099 I figured there was an issue with how I was connecting to it. A little googling revealed that the jnp url could specified manually. I have added it to my jboss_init_redhat.sh script changing the folowing 3 lines as shown:
#JBOSS_BIND_ADDR=${JBOSS_HOST:+"-b $JBOSS_HOST"}
JBOSS_BIND_ADDR="192.168.1.24"
#JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh -c $JBOSS_CONF $JBOSS_BIND_ADDR"
JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh -c $JBOSS_CONF -b $JBOSS_BIND_ADDR"
#JBOSS_CMD_STOP=${JBOSS_CMD_STOP:-"java -classpath $JBOSSCP org.jboss.Shutdown --shutdown"}
JBOSS_CMD_STOP="$JAVA_HOME/bin/java -classpath $JBOSSCP org.jboss.Shutdown -s jnp://$JBOSS_BIND_ADDR:1099 -
-shutdown"
I also added an echo statement for my shutdown command so that it would be clear what was happenning:
jboss_user@server_name:/opt/jboss/jboss-5.1.0.GA/bin% ./jboss_init_redhat.sh stop
JBOSS_CMD_STOP = /opt/java/jdk1.6.0_12/bin/java -classpath /opt/jboss/jboss-5.1.0.GA/bin/shutdown.jar org.jboss.Shutdown -s jnp://192.168.1.24:1099 --shutdown
Shutdown message has been posted to the server.
Server shutdown may take a while - check logfiles for completion
I hope this saves some of you some time and energy in getting a stock Jboss 5.1.0.GA up and running - (as well as stopping correctly)