Sunday, April 3, 2011

JBoss service shutdown issue

I recently installed Jboss-5.0.0.GA version on my Linux environment and configured the Application server to run as a service as per the below guidelines.


Jboss Run the Application Server as a Service


I was able to start the jboss application server by using the service but i couldn't stop the service. It was throwing the following exception while stopping jboss service.


hostname018:/opt/jboss-5.0.0.GA/bin # /etc/init.d/jboss_eap stop
JBOSS_CMD_START = cd /opt/jboss-5.0.0.GA/bin; /opt/jboss-5.0.0.GA/bin/run_custom.sh
Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: hostname018.domain.com:1099 [Root exception is javax.naming.CommunicationException: Failed to connect to server hostname018.domain.com:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server hostname018.domain.com:1099 [Root exception is java.net.ConnectException: Connection refused]]]
        at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1727)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:680)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:673)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at org.jboss.Shutdown.main(Shutdown.java:219)
Caused by: javax.naming.CommunicationException: Failed to connect to server hostname018.domain.com:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server hostname018.domain.com:1099 [Root exception is java.net.ConnectException: Connection refused]]
        at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:311)
        at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1698)
        ... 4 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server hostname018.domain.com:1099 [Root exception is java.net.ConnectException: Connection refused]
        at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:281)
        ... 5 more
Caused by: java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:97)
        at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:82)
        at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:277)
        ... 5 more
hostname018:/opt/jboss-5.0.0.GA/bin #


I found the interesting solution for this issue after enough investigation. This might save some of your precious time during your installation/configuration.

I made sure that this exception is nothing to do with the service configuration. I was getting this exception even though i use the shutdown_custom.sh command to stop the service. Then i tried the following telnet command to make sure that my service is listening to port which is used for shutdown process. 

hostname018:~# telnet hostname018.domain.com 1099

Then I found the weired thing that it first tried to map it to the some unknown IP address and then connects to the it's own IP address as below.

hostname018:~# telnet hostname018.domain.com 1099
Trying 192.168.4.88...
telnet: connect to address 192.168.4.88: Connection refused
Trying 152.141.186.188...
Connected to hostname018.domain.com.
Escape character is '^]'.


Then i got a clue and verified the host file entry. Found the interesting thing here, this domain name was mapped to some irrelevant IP address 192.168.4.88 in the host file. 

Jboss service shutdown service is working as expected without any issues after removing the irrelevant host file entry.

No comments: