2

I am trying to shutdown and start my tomcat after i uploaded new war file. but i am getting Connection refused error while shutdown the tomcat instance. the error is below ,

Oct 31, 2015 2:55:44 AM org.apache.catalina.startup.Catalina stopServer
SEVERE: Could not contact localhost:8005. Tomcat may not be running.
Oct 31, 2015 2:55:44 AM org.apache.catalina.startup.Catalina stopServer
SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at java.net.Socket.connect(Socket.java:538)
        at java.net.Socket.<init>(Socket.java:434)
        at java.net.Socket.<init>(Socket.java:211)
        at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:498)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:370)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:457)

Tomcat stopped

Even i killed running java id using kill -9 PID but still i am getting same error and i can not start my application.

How to fix this and shutdown my tomcat without bug ?

MMMMS
  • 2,179
  • 9
  • 43
  • 83
  • I think the thing is not about stopping server, but about starting server ,you should post the error message when you start the server(there should be some) . – 柯鴻儀 Oct 31 '15 at 07:10
  • Possible duplicate http://stackoverflow.com/questions/5698802/apache-tomcat-java-net-connectexception-connection-refused – Shiladittya Chakraborty Oct 31 '15 at 07:10

3 Answers3

1

If its windows try below to kill the running tomcat process

C:\Users\Saravana.Saravana-PC>netstat -ano  | find ":8080"
  TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       1448
  TCP    127.0.0.1:8080         127.0.0.1:49543        ESTABLISHED     1448
  TCP    127.0.0.1:49543        127.0.0.1:8080         ESTABLISHED     4068
  TCP    [::]:8080              [::]:0                 LISTENING       1448
  TCP    [::1]:8080             [::1]:49542            ESTABLISHED     1448
  TCP    [::1]:49542            [::1]:8080             ESTABLISHED     4068

C:\Users\Saravana.Saravana-PC>taskkill.exe /PID 1448 /F
SUCCESS: The process with PID 1448 has been terminated.

C:\Users\Saravana.Saravana-PC>

In Linux if stopTomcat.sh is not stopping tomcat then

ps -ef | grep "tomcat"
kill -9  <PID>

kill the running instance of tomcat, killing your java application wont kill tomcat

To get the running tomcat port use sudo netstat -lnp | grep <PID>

Saravana
  • 12,647
  • 2
  • 39
  • 57
  • I am using linux so i used ps -ef | grep "tomcat" and killed the corresponded running PID and again i started tomcat and shutdown tomcat but same issue rising :( – MMMMS Oct 31 '15 at 07:28
  • did you check the logs? what exception are you getting? – Saravana Oct 31 '15 at 07:31
  • It shows java.net.BindException: Address already in use :8105 – MMMMS Oct 31 '15 at 07:35
  • are you running any other service on port 8105? it looks like some other process is already using this port. grep`sudo netstat -lnp` with the port, it'll show the process using the port, kill the process and try – Saravana Oct 31 '15 at 07:39
  • I checked using netstat -lnp 8105 but i dont find the 8105 is listening – MMMMS Oct 31 '15 at 07:42
  • please post the o/p of `sudo netstat -lnp | grep 8105` – Saravana Oct 31 '15 at 07:43
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/93853/discussion-between-m-manivasagam-and-uuid). – MMMMS Oct 31 '15 at 07:45
0

I cleaned my webapps and it helped me:

cd /opt/tomcat/webapps
shopt -s extglob
rm -rf !(ROOT|balancer|webdav)

after that, I was able to deploy my application

NargesooTv
  • 837
  • 9
  • 15
-1

Try changing the port number from 8005 to some other port number and restart Eclipse .

sometimes it may happen that the port number is blocked by sudden termination of process

Saketh Kotha
  • 101
  • 1
  • 1
  • 10