Linux Tomcat Errors Linux Tomcat Errors linux linux

Linux Tomcat Errors


Update

I've decoded the ELF header from your error message: ^?ELF^A^A^A^B^C^A

It is a bunch of caret encoded control characters,which can be decoded as follows:

First 4 bytes are a magic number, identifying the file as an ELF executable.

0x7f (^?) - ELFMAG0 0x45 (E)  - ELFMAG10x4c (L)  - ELFMAG20x46 (F)  - ELFMAG3

Next 3 bytes specify the architecture, the endianness and the ELF format version:

0x01 (^A) - ELFCLASS32  (i.e. this is a 32 bit binary)0x01 (^A) - ELFDATA2LSB (Little Endian)0x01 (^A) - EI_VERSION  (Version of ELF format EV_CURRENT/1)

So basically it is a 32-bit Java binary.

Then, I've downloaded the 32-bit version of JRE (jre1.8.0_121), and tried to run java with dash, to confirm my shell issue theory (below), and it does indeed produce exactly the same error message you have:

%dash ./java|&less./java: 1: ./java: ^?ELF^A^A^A^B^C^A: not found./java: 2: ./java: Syntax error: "(" unexpected

So, most probably, you are using a 32-bit version of Java (as bundled with your Tomcat), on a machine, which is not capable (or configured) to run 32-bit executables. And a shell issue (as described below), then masks the underlying problem, which is why you get this weird looking error message.

It is hard to say more without having a bit more details on your system,so output of uname -a and cat /etc/lsb-release would be nice to have.


...

My bet is that this might be a shell issue, i.e. your /bin/sh points to something like dash, which might cause some compatibility issues with catalina.sh script, and make it interpret bin/java as a script, instead of running it as an executable, under certain circumstances.

In particular older versions of dash are known to executes binary data as a shell script in case of ENOEXEC (i.e. corrupted and/or invalid architecture binary) (see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=816313;msg=5).

And your error message

/home/tomcat/jdk1.8.0_121/bin/java: 2: /home/tomcat/jdk1.8.0_121/bin/java: Syntax error: "(" unexpected

looks very much like it.

You can check what your /bin/sh points to, like that:

>ls -l /bin/sh/bin/sh -> bash

If it is not bash, then modify the shebang line in your /home/tomcat/apache-tomcat-8.5.11/bin/catalina.sh as follows:

#!/bin/bash

and see if it helps, or at least produces a more readable error message.

In case bash fails with cannot execute binary file, check if your java binary is not corrupted and can be executed on your system, by running it by hand:

/home/tomcat/jdk1.8.0_121/bin/java