Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Tomcat Errors

I'm having trouble launching tomcat on my linux server. I run startup.sh, and get the Tomcat Started logging, but then can't access anything on localhost:8080.

$CATALINA_HOME/bin/startup.sh
Using CATALINA_BASE:   /home/tomcat/apache-tomcat-8.5.11
Using CATALINA_HOME:   /home/tomcat/apache-tomcat-8.5.11
Using CATALINA_TMPDIR: /home/tomcat/apache-tomcat-8.5.11/temp
Using JRE_HOME:        /home/tomcat/jdk1.8.0_121
Using CLASSPATH:       /home/tomcat/apache-tomcat-8.5.11/bin/bootstrap.jar:/home                                                                                        /tomcat/apache-tomcat-8.5.11/bin/tomcat-juli.jar
Tomcat started.

Checking the logs/catalina.out file, there are the following lines in there, but I haven't been able to find any information about these errors.

/home/tomcat/jdk1.8.0_121/bin/java: 1: /home/tomcat/jdk1.8.0_121/bin/java: ^?ELF^A^A^A^B^C^A: not found
/home/tomcat/jdk1.8.0_121/bin/java: 2: /home/tomcat/jdk1.8.0_121/bin/java: Syntax error: "(" unexpected

Any ideas?

like image 991
leedsunited92 Avatar asked Feb 04 '17 15:02

leedsunited92


People also ask

Where you can see the Tomcat errors?

This file is located in the logs directory below the Tomcat root directory. This log is the system's output log, which also consists of standard error messages. These files are saved daily (MM-DD-YYYY) with the date appended to the name of the data.

How do I view Tomcat logs in Linux?

The main Apache Tomcat configuration file is at /opt/bitnami/tomcat/conf/server. xml. Once Apache Tomcat starts, it will create several log files in the /opt/bitnami/tomcat/logs directory.

What is difference between Apache and Apache Tomcat?

Key difference between Tomcat and the Apache HTTP Server the Apache HTTP Server, but the fundamental difference is that Tomcat provides dynamic content by employing Java-based logic, while the Apache web server's primary purpose is to simply serve up static content such as HTML, images, audio and text.


1 Answers

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)  - ELFMAG1
0x4c (L)  - ELFMAG2
0x46 (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
like image 86
zeppelin Avatar answered Oct 10 '22 04:10

zeppelin