8

I always get this message that I can't follow:

sudo systemctl status -l tomcat8.service
● tomcat8.service - LSB: Start Tomcat.
   Loaded: loaded (/etc/init.d/tomcat8)
   Active: failed (Result: exit-code) since sáb 2015-05-09 00:48:07 CEST; 2h 31min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1295 ExecStart=/etc/init.d/tomcat8 start (code=exited, status=127)

may 09 00:48:07 vaio systemd[1]: Starting LSB: Start Tomcat....
may 09 00:48:07 vaio tomcat8[1295]: [58B blob data]
may 09 00:48:07 vaio systemd[1]: tomcat8.service: control process exited, code=exited status=127
may 09 00:48:07 vaio systemd[1]: Failed to start LSB: Start Tomcat..
may 09 00:48:07 vaio systemd[1]: Unit tomcat8.service entered failed state.
may 09 00:48:07 vaio systemd[1]: tomcat8.service failed.

Any idea?

Thank you in advance!!

1

8 Answers 8

5

I had the same error when I upgraded Ubuntu and also Java (8->11). The problem was a wrong JAVA_HOME path inside the systemd module. The JAVA_HOME path had "jre/" at the end which is wrong for newer Java versions. Solution:

  1. Edit /etc/systemd/system/tomcat.service and remove the trailing "jre/" of the JAVA_HOME path.
  2. systemctl daemon-reload
  3. systemctl restart tomcat
1
  • Worked for me! I followed a fast guide for java 8 :)
    – Genaut
    Mar 17, 2020 at 21:26
1

Value 127 is returned by /bin/sh when the given command is not found within your PATH system variable and it is not a built-in shell command. In other words, the system doesn't understand your command, because it doesn't know where to find the binary you're trying to call.

for more info LINK

0

Something must got corrupted in the installation of Tomcat. I could not do apt-get remove tomcat8 nor apt-get purge tomcat8. I deleted the conf folder and saved my server.xml file and webapps folders. Then I was able to do a purge of tomcat followed by a fresh install and replacement of server.xml file with mine and I was running again.

Still do not know what corrupted the tomcat installation, but I was finally able to move on.

Thank you all for your suggestions.

0

Hi All i got something its working for me,so please try my procedure

First goto service file in init.d

/etc/init.d/tomcat8

turn out into a execution file by adding below code at tomcat8

#!/bin/sh

Some times Java Home is not properly set at environment so Export the java home and set process id (PID) for tomcat in Catalina.sh file

Go to /Tomcat/bin/catalina.sh 

Add the following codes at the starting of catalina.sh file

For exporting java home, Use the respected java version to set path i actually installed java at /usr/java/

JAVA_HOME=/usr/java/jdk1.7.0_60 
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME

It the last step now add the tomcat pid for catalina add the following code after setting java home

CATALINA_PID=/var/run/tomcat.pid

Now go to terminal start the tomcat service

service tomcat8 start

We need to reload system deamon

systemctl daemon-reload

its worked out for me feel free to ask questions

this happens in ubuntu 15.04

/etc/default files which enable/disable jobs enable=1|0 type settings in /etc/default files should generally be avoided. The canonical way to enable/disable a service in an init system agnostic way is update-rc.d enable|disable, which will translate to init system specific actions such as adding/removing symlinks (SysV and systemd) or creating/removing job override files (upstart). For systemd in particular, admins also often call systemctl enable|disable directly. Thus these settings are redundant in /etc/default

source:wiki.ubuntu.com/SystemdForUpstartUsers

0

The issue is with /etc/init.d/tomcat8, java folder detection

find_jdks()
{
  for java_version in 9 8 7
  do
      for jvmdir in /usr/lib/jvm/java-${java_version}-openjdk-* \
                    /usr/lib/jvm/jdk-${java_version}-oracle-* \
                    /usr/lib/jvm/jre-${java_version}-oracle-*
      do
          if [ -d "${jvmdir}" ]
          then
              JDK_DIRS="${JDK_DIRS} ${jvmdir}"
          fi
      done
  done

  # Add older non multi arch installations
  JDK_DIRS="${JDK_DIRS} /usr/lib/jvm/java-7-oracle"
}

So if it can't find java under /usr/lib/jvm/jre-${java_version}-oracle-* folder it was defaulting to java-7-oracle which was for java 7 if you have installed using apt-get; you will need to fix that to default to java-8-oracle.

So, I had to change JDK_DIRS="${JDK_DIRS} /usr/lib/jvm/java-7-oracle" to JDK_DIRS="${JDK_DIRS} /usr/lib/jvm/java-8-oracle" to get this working

1
  • This problem has been fixed. /etc/init.d/tomcat8 now has the a line for /usr/lib/jvm/java-${java_version}-oracle which will pick up on /usr/lib/jvm/java-8-oracle. It is also possible to edit /etc/default/tomcat8 and set the JAVA_HOME variable. If you do that, it will use what is set and not try all the logic to figure it out. Apr 26, 2017 at 11:58
0

I got this error because I was setting JAVA_HOME in /usr/share/tomcat8/bin/setenv.sh. The services script for tomcat /etc/init.d/tomcat8 instead wants you set up the tomcat environment in /etc/default/tomcat8. Once I put my settings into /etc/default/tomcat8 then deleted /usr/share/tomcat8/bin/setenv.sh tomcat started up just fine.

The reason appears to be that /etc/init.d/tomcat8 tries to figure out which JVM is used but ignores /usr/share/tomcat8/bin/setenv.sh. It uses the JVM info to look at the process list and see if tomcat is running. If you use setenv.sh, tomcat gets started with a different JVM than the one that init.d expects. It then can't see it in the process list and reports that it failed to start.

0

In my case JAVA_HOME path was incorrect

change it by editing

/etc/systemd/system/tomcat.service 

and remove the trailing "jre/"` of the JAVA_HOME path.

/usr/lib/jvm/java-1.11.0-openjdk-amd64/jre

it will look something like this after editing

/usr/lib/jvm/java-1.11.0-openjdk-amd64/

now do

  1. systemctl daemon-reload
  2. systemctl restart tomcat
-1

i also got this error while starting tomcat service.in tomcat.service file when i checked [Service] section then i find that jre was not created so i remove the jre word.First it was like this "Environment=JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64/jre" i removed jre and it became like this "Environment=JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64" after that i started service.it worked.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .