1

When I attempt to startup Tomcat (7.0.82) on RHEL6/Java7, the logs will display this:

Error: Could not find or load main class

Notice, no specific class specified at the end of the log entry. Most hits on google seem to indicate a specific class at the end of the log entry.

In my case, I have these two servers configured identically (AFAIK). However, one server doesn't want to start. The server was installed using downloadeded binaries, custom init script, etc; using an Ansible script that worked on 3 servers in total (all same OS, Java) thus far.

Issued command: service tomcat start

Server A - Works

Using CATALINA_BASE:   /opt/tomcat/current
Using CATALINA_HOME:   /opt/tomcat/current
Using CATALINA_TMPDIR: /opt/tomcat/current/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/tomcat/current/bin/bootstrap.jar:/opt/tomcat/current/bin/tomcat-juli.jar
Tomcat started.

Server B - Doesn't (Even though indicates "started")

Using CATALINA_BASE:   /opt/tomcat/current
Using CATALINA_HOME:   /opt/tomcat/current
Using CATALINA_TMPDIR: /opt/tomcat/current/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/tomcat/current/bin/bootstrap.jar:/opt/tomcat/current/bin/tomcat-juli.jar
Tomcat started.

Update #1

Output of catalina.out

[me@server tomcat]$ cat /var/log/tomcat/catalina.out
Error: Could not find or load main class

Update #2

Output of version.sh and configtest.sh

version.sh

[me@server bin]$ ./version.sh
Using CATALINA_BASE:   /opt/tomcat/apache-tomcat-7.0.82
Using CATALINA_HOME:   /opt/tomcat/apache-tomcat-7.0.82
Using CATALINA_TMPDIR: /opt/tomcat/apache-tomcat-7.0.82/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/tomcat/apache-tomcat-7.0.82/bin/bootstrap.jar:/opt/tomcat/apache-tomcat-7.0.82/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.82
Server built:   Sep 29 2017 12:23:15 UTC
Server number:  7.0.82.0
OS Name:        Linux
OS Version:     2.6.32-696.13.2.el6.x86_64
Architecture:   amd64
JVM Version:    1.7.0_45-b18
JVM Vendor:     Oracle Corporation

configtest.sh

[me@server bin]$ ./configtest.sh
Using CATALINA_BASE:   /opt/tomcat/apache-tomcat-7.0.82
Using CATALINA_HOME:   /opt/tomcat/apache-tomcat-7.0.82
Using CATALINA_TMPDIR: /opt/tomcat/apache-tomcat-7.0.82/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/tomcat/apache-tomcat-7.0.82/bin/bootstrap.jar:/opt/tomcat/apache-tomcat-7.0.82/bin/tomcat-juli.jar
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version:        Apache Tomcat/7.0.82
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          Sep 29 2017 12:23:15 UTC
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number:         7.0.82.0
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Linux
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            2.6.32-696.13.2.el6.x86_64
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             /usr/java/jre1.7.0_45
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.7.0_45-b18
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         /opt/tomcat/apache-tomcat-7.0.82
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         /opt/tomcat/apache-tomcat-7.0.82
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/opt/tomcat/apache-tomcat-7.0.82/endorsed
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/opt/tomcat/apache-tomcat-7.0.82
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/opt/tomcat/apache-tomcat-7.0.82
Nov 30, 2017 10:13:59 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.io.tmpdir=/opt/tomcat/apache-tomcat-7.0.82/temp
Nov 30, 2017 10:13:59 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Nov 30, 2017 10:14:00 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Nov 30, 2017 10:14:00 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Nov 30, 2017 10:14:00 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1881 ms
  • Could you add more detailed log? Also you could try the following: bash -x /etc/init.d/tomcat start – ALex_hha Nov 29 '17 at 22:02
  • That's all it gives. I have tail running and at every restart, that's all it gives out. – TekiusFanatikus Nov 30 '17 at 0:02
  • I ran your command, gave me the same output in my logs/terminal. FYI. – TekiusFanatikus Nov 30 '17 at 13:00
  • 2
    Are you sure? Because it should contain much more output. What in the /etc/init.d/tomcat? One more thing - did you check JAVA_OPTS? I had similar issue with Jenkins, when there was incorrect JAVA_OPTS set in the /etc/sysconfig/tomcat8 – ALex_hha Nov 30 '17 at 16:35
  • Reformatted my entire setenv.sh file, now getting more output! – TekiusFanatikus Nov 30 '17 at 17:06
3

setenv.sh had encoding issues and improper EOL. Once those were fixed, things were up and running like expected.

1

This issue is directly linked to your setenv.sh and, as pointed above, is due to improper encoding and formatting issues. In my case there were two errors:

  1. Extra spaces in VMargs. Example:

Dcatalina.base= /some/location or Dcatalina.base =/some/location or Dcatalina.base = /some/location

are wrong because of spaces around the '='.

  1. The second issue was related to line endings. Make sure if you using unix/linux, your setenv.sh must be saved with unix styled line endings. (Can be done in Notepad++ or gedit while saving). Whereas if you are using Windows, your setenv.bat must have windows styled line endings.

One way to check this is to try to run setenv.sh by doing ./setenv.sh. If it does not show any output, your formatting is fine.

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.