Tomcat on CentOS 6.5 starts the error reporting problem resolution

  • 2020-05-10 23:22:52
  • OfStack

Here are two mistakes:

1. The first error, the problem of APR, error details:

The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path

2. Error no. 2, error details:

Exception in thread "main" java.lang.InternalError
              at sun.security.ec.SunEC.initialize(Native Method)
              at sun.security.ec.SunEC.access$000(SunEC.java:49)
              at sun.security.ec.SunEC$1.run(SunEC.java:61)

 
Solution to the first problem:

This is a problem with 1 APR, because Tomcat relies on APR to optimize performance, so you need to install APR

1. First, install APR, which is installed in the form of source code. By default, it is installed in: /usr/local/apr


wget    http://mirrors.cnnic.cn/apache//apr/apr-1.5.2.tar.gz
tar -zxvf apr-1.5.0.tar.gz
cd apr-1.5.0
./configure
make
make install

2. Next, install Tomcat-native. The gz package already exists under the bin directory of Tomcat.

Go to cd     tomcat-native-1.2.7-src /native, then compile and install:

./configure --with-apr=/usr/local/apr   --with-java-home="/usr/lib/jvm/java-1.7.0" --with-ssl=yes

If the Tomcat version downloaded is relatively new, there will be a problem that the OpenSSL version is not 1, and the installation cannot be done. The following error occurs:

checking OpenSSL library version > = 1.0.2... configure: error: Your version of OpenSSL is not compatible with this version of tcnative

To do this, download a version of the Tomcat-native package, which is 1 point lower:

wget       http://mirrors.hust.edu.cn/apache/tomcat/tomcat-connectors/native/1.1.34/source/tomcat-native-1.1.34-src.tar.gz

After the above gz package is downloaded, put it into the bin directory of Tomcat, unzip it, and enter the directory: cd tomcat-native-1.1.20-src /jni/native, and then compile and install it

3. After successful compilation and installation, create a new file named setenv.sh in the bin directory of Tomcat

Add content to new file:

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CATALINA_HOME/lib
                export LD_LIBRARY_PATH
4. After the above three steps, the first question can be solved;

Solution to the second problem:

This is caused by the version of JDK. I installed OpenJDK, and the JAR package will be missing, resulting in startup error. Therefore, it needs to be replaced with JDK officially provided by Oracle

1, to Oracle official download a package that jdk - 7 u79 - linux - x64. tar. gz

2. After unzip, move to /usr/local/java

3. Add environment variables: vim     /etc/profile. Add the following lines at the end of the file


export JAVA_HOME=/usr/local/java/jdk1.7.0_79   // The actual JDK The path
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

4. After completing the above installation, start Tomcat again and find that there will be an error: Neither the JAVA_HOME nor the JRE_HOME environment is is defined

The problem is that Tomcat does not recognize JDK's environment variables

5. Modify the catalina. sh file of the bin directory in Tomcat by adding the following code at the beginning of the file:


export JAVA_HOME=/usr/local/java/jdk1.7.0_79  //// The actual JDK The path
export JRE_HOME=/usr/local/java/jdk1.7.0_79/jre

Finally, launch Tomcat, the log print is normal, the browser can also access, problem solved

Exception in thread "main" java.lang.InternalError
              at sun.security.ec.SunEC.initialize(Native Method)
              at sun.security.ec.SunEC.access$000(SunEC.java:49)
              at sun.security.ec.SunEC$1.run(SunEC.java:61)


Related articles: