The problem cannot be completely closed after Tomcat executes the shutdown method.

Source: Internet
Author: User

Tomcat is rewritten to respond to new Protocol requests.

After the rewrite is completed, debug on eclipse has no task problem, and then compress the changed Tomcat into a jar package, replace the jar package in the Lib folder in the original APACHE-Tomcat-6.0.37 directory.

After startup. Sh is executed, everything is normal, and the program and debug result are consistent.

However, after a shutdown operation is executed, startup is executed again to find that the Mapper object cannot be obtained.

PS-Ef finds that many Java processes are not closed, so it is considered that the thread is still not closed after Tomcat stops running because the thread's lifecycle is not well controlled.

Go to the bin folder in the java_home directory and find the command jstack. jstack is used to print the java stack information of the given JAVA process ID or core file or remote debugging service.

Command Format:

Jstack [Option] PID
Jstack [Option] executable Core
Jstack [Option] [[email protected] Remote-hostname-or-IP

 

After jstack is used to print information, two unfinished processes and other processes that cannot be closed due to these processes are found. Therefore, Tomcat cannot be completely closed after the shutdown command is executed, this causes a Bug During the second startup.

 

Locate the two processes and find that the while (true) is used in the run () method to make the program unable to terminate correctly. Finally, in the destroy method implemented in the newly written protocol class, the while condition of the two threads is restricted so that the destroy method can end the two processes and solve the problem.

 

The problem cannot be completely closed after Tomcat executes the shutdown method.

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.