The issue of switching openjdk to Oracle JDK in CentOS will cause Tomcat to not start properly

Source: Internet
Author: User

Set the JDK environment variable, and the command line uses java-version

Use the service tomcat-web1 Start command to report the following error
Neither the Java_home nor the JRE_HOME environment variable is defined. At least one of these environment variable are needed to run this program

Note: TOMCAT-WEB1 is the Tomcat service name, Tomcat set up the service method online there are many no longer repeat

One way is to modify the setclasspath.sh, adding at the beginning of the SH script
java_home=/usr/lib/java-1.7.0
But this method is not good, if the Java home changes also need to modify the shell

So in a different way, look at the shell script first.

catalina_home_data=/usr/local/tomcat/tomcat7.< Span class= "Hljs-number" >0  start_tomcat= $CATALINA _home_data /bin/ Startup.shstop_tomcat= $CATALINA _home_data /bin/shutdown.sh start   () {${start_tomcat}  if  [$? -eq  0 ];        then  printf      "Tomcat7-data started \t\t\t\t\t[\033[32m ok \033[m]\n" ;        else  printf      "Tomcat7-data started \t\t\t\t\t[\033[31m FAIL \033[m]\n" ; fi }  

The

service runs the specified services (known as the System V initial script), removing most of the environment variables, preserving only the Lang and term environment variables, and setting the current path to/, that is, running the service script in a very clean environment that can be predicted.
The environment variable cannot be found while the script is running, so modify it to the following script

catalina_home_data=/usr/local/tomcat/tomcat7. 0  start_tomcat= $CATALINA _home_data /bin/ Startup.shstop_tomcat= $CATALINA _home_data /bin/shutdown.sh start   () {su-root-c  "${start_tomcat} "  if  [$?] -eq  0 ]; then  printf   "Tomcat7-data started \t\t\t\t\t[\033[32m ok \033[m]\n" ; else  printf   "Tomcat7-data started \t\t\t\t\t[\033[31m FAIL \033[m]\n" ; fi } 

Su-root-c "${start_tomcat}"
-Represents the execution environment variable
-C is the Execute command
The overall command means to execute the/usr/local/tomcat/tomcat7.0/bin/startup.sh command in the same way as the root user and with environment variables

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The issue of switching openjdk to Oracle JDK in CentOS will cause Tomcat to not start properly

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.