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.