2

I have an Ubuntu 16.04 fresh installation, where I have installed Tomcat7 using apt-get install, and I'm having some problems trying to interact with the service using the service command.

I understand that if Tomcat is installed on system, the correct way to interact with the service is using the service command.

After a system reboot, I see that Tomcat7 is deploying a war application as expected, and everything looks to be working correctly in the web application.

But if I want to restart my Tomcat:

sudo service tomcat7 restart

I see in catalina.out log that there are some errors caused by the address is already in use. There are any other application using the same port.

If I try to stop the tomcat, using as always service tomcat7 stop:

usr@Srv2:~$ sudo service tomcat7 stop
[sudo] password for qgenviewer: 
usr@Srv2:~$ ps -aux | grep tomcat7
tomcat7    1409  2.5  2.3 9268692 377788 ?      Sl   12:11   0:27     /usr/lib/jvm/java-7-openjdk-amd64/bin/java -Djava.util.logging.config.file=/var/lib/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.awt.headless=true -Xms512m -Xmx6144m -XX:+UseConcMarkSweepGC -Djava.endorsed.dirs=/usr/share/tomcat7/endorsed -classpath /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar -Dcatalina.base=/var/lib/tomcat7 -Dcatalina.home=/usr/share/tomcat7 -Djava.io.tmpdir=/tmp/tomcat7-tomcat7-tmp org.apache.catalina.startup.Bootstrap start
usr+   1762  0.0  0.0  21316   924 pts/0    S+   12:29   0:00 grep --    color=auto tomcat7

So it looks like service command is not working because Tomcat is still running. If I try service tomcat7 status, the output is as follows:

usr@Srv2:~$ sudo service tomcat7 status
● tomcat7.service - LSB: Start Tomcat.
   Loaded: loaded (/etc/init.d/tomcat7; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since vie 2016-05-06 12:11:29 CEST; 21min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1356 ExecStart=/etc/init.d/tomcat7 start (code=exited, status=1/FAILURE)
    Tasks: 38 (limit: 512)
   CGroup: /system.slice/tomcat7.service
           └─1409 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -Djava.util.logging.config.file=/var/lib/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.C

may 06 12:11:24 Srv2 systemd[1]: Starting LSB: Start Tomcat....
may 06 12:11:24 Srv2 tomcat7[1356]:  * Starting Tomcat servlet  engine tomcat7
may 06 12:11:29 Srv2 tomcat7[1356]:    ...fail!
may 06 12:11:29 Srv2 systemd[1]: tomcat7.service: Control process exited, code=exited status=1
may 06 12:11:29 Srv2 systemd[1]: Failed to start LSB: Start Tomcat..
may 06 12:11:29 Srv2 systemd[1]: tomcat7.service: Unit entered failed state.
may 06 12:11:29 Srv2 systemd[1]: tomcat7.service: Failed with result 'exit-code'.
may 06 12:28:38 Srv2 systemd[1]: Stopped LSB: Start Tomcat..

Any help of what is happening...? It finally looks like service tomcat7 is not working. What could be the cause? Then, who is starting the tomcat service on system startup? And how I could stop or restart the tomcat7 service?

Thank you for your time.

Edit

In order to give more information, and following the advice of @Jens Grivolla, this is the output for pstree:

usr@Srv2:~$ pstree -lsup 1409
systemd(1)───java(1409,tomcat7)─┬─{java}(1412)
                                ├─{java}(1418)
                                 ...
                                ├─{java}(2262)
                                └─{java}(2313)
  • Have you looked at any other log files e.g. messages? – Cipher Menial Jun 23 '17 at 1:03
1

You can try the following:

  • First get the PID of the running tomcat service, e.g. $ ps aux|grep tomcat
  • Then try to see how it was launched using pstree (use man pstree to understand the options used), e.g.

    $ pstree -lsup 26276
    systemd(1)───java(26276,tomcat7)─┬─{java}(26277)
                                     ├─{java}(26278)
                                     ├─{java}(26279)
                                     ├─{java}(26280)
                                     ├─...
                                     └─{java}(1252)
    

So in my case it was clearly launched by systemd. If you see something different, then at least you have an idea where to investigate...

|improve this answer|||||
  • Thanks for that, I've edit my question, adding the output of the pstree, and it looks like, also in my case, tomcat was launched by systemd. – xarmengol May 6 '16 at 12:49
  • Sorry, I have no idea where to go from there. Of course you could have several service definitions for tomcat (e.g. one called tomcat7 and another called tomcat), but that seems rather unlikely. – Jens Grivolla May 7 '16 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.