2

I have 2 Spring boot projects running on same tomcat:

  1. REST-API
  2. Background Service (BS)

Purpose

  1. REST-API : UI application uses this to get things done.
  2. BS : Based on UI activity this service gets executed and gets things done on Real-time .

Details
BS is written as while(1) considering the purpose of the same.

Tomcat Error
1st Attempt:

Using CATALINA_PID:    /home/user/bin/pid/tomcat_pid  
Tomcat did not stop in time.  
PID file was not removed.  
To aid diagnostics a thread dump has been written to standard out  

2nd Attempt:

java.net.ConnectException: Connection refused (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:492)  
        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:498)  
        at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:406)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495)
The stop command failed. Attempting to signal the process to stop through OS signal.
Tomcat stopped.

Problems:
1. When I restart tomcat, BS project will only be running and REST-API does not get started (I guess this happens because of while(1) it starts executing and not giving chance to start REST-API project )
2. While stopping tomcat it does not get stopped in a single attempt, when we try to stop one more time then it gets stopped.

1 Answers1

-1

This exception mostly indicates that there is no service listening on the IP/port you are trying to connect to, so ,you are trying to connect to the wrong IP/port, or the server is not started.

Vasanth Raghavan
  • 162
  • 2
  • 12
  • Is your tomcat server up and running ? – Vasanth Raghavan Jan 07 '19 at 10:49
  • Yes once we deploy `BS` then it goes into hang state i.e, `catalina.log` do not write anything while `BS` logs are working fine. –  Jan 07 '19 at 16:40
  • 2
    is your application consuming too much memory ? that can cause these crashes potentially. Open the catalina.bat file in /bin directory. Add the line :set JAVA_OPTS=%JAVA_OPTS% -Xms1024m -Xmx1024m where Xms is the initial (start) memory pool,Xmx is the maximum memory pool Xss is the thread stack size – Vasanth Raghavan Jan 23 '19 at 06:53