The reason for this
- Learn the use of Tomcat software
environment
- Tomcat version: 8.5.75
- jdk version: jdk-16.0.2
- Computer system: win10
Problems and remedies
Start Tomcat
- question
My system is win10, so you need to start the file below the bin directory to open Tomcat. But if you double-click the file, you will crash. - search
Search through search engines found that this happens because the JAVA environment variable is not configured correctly. - result
But I've configured it before. Use the cmd command window to enter the following commands:java
、javac
、java -version
None of them have any problems.
Download jre
- search
Search through search engines to find: the shadow of jre was found. It turns out that after the jdk11 version, downloading jdk no longer comes with jre, so you need to download it yourself. Sure enough, when you open the downloaded jdk-16.0.2, there is no jre in it. - Revise
By AdministratorOpen the cmd command and enter the jdk folder.
The location of the jdk I downloaded here is located inE:\JAVA
, therefore, it is necessary toE:\JAVA\jdk-16.0.2
Open the cmd command below and type the following code:bin\ --module-path jmods --add-modules --output jre
。
Then you will find that there is an additional jre folder under the jdk-16.0.2 folder. Then configure the environment variable of jre, that is, JRE_HOME:E:\JAVA\jdk-16.0.2\jre Path:%JRE_HOME%\bin - result
Double-clicking to open the file still crashes and has no effect.
Modify the source code
search
Search through search engines found that it is still possible that the environment variable configuration error is still configured. Check the source code and you will find that ->->, there is a layered relationship between them.Revise
So we can declare environment variables under the file and add our own local jdk and jre paths.
Right-click to open the file through Notepad, and then enter it at the top of the file code.
set JAVA_HOME=E:\JAVA\jdk-16.0.2(jdkpath) set JRE_HOME=E:\JAVA\jdk-16.0.2\jre(jrepath)
result
Double-click to open it, this time it flashed twice, but it still couldn't be opened.
Check port number
- search
Search through search engines found that it is possible that other applications occupy the port number - Revise
Use the cmd command to check whether other applications occupy the 8080 port number, typenetstat -aon|findstr “8080”
。 - result
No software occupies.
Capture error messages
search
Search through search engines to discover: error information can be viewed by capturing.-
Revise
There are two error methods below to capture error information, and you can choose any one.
Right-click the file, open it through Notepad, and modify the third last line.
call "%EXECUTABLE%" start %CMD_LINE_ARGS% # Modify to the following codecall "%EXECUTABLE%" run %CMD_LINE_ARGS%
- Save, and then open the file as a cmd command. This will appear in the cmd window
Using CATALINA_BASE: "E:\Tomcat\apache-tomcat-8.5.75" Using CATALINA_HOME: "E:\Tomcat\apache-tomcat-8.5.75" Using CATALINA_TMPDIR: "E:\Tomcat\apache-tomcat-8.5.75\temp" Using JRE_HOME: "E:\JAVA\jdk-16.0.2\jre" Using CLASSPATH: "E:\Tomcat\apache-tomcat-8.5.75\bin\;E:\Tomcat\apache-tomcat-8.5.75\bin\" Using CATALINA_OPTS: "" NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=/=ALL-UNNAMED --add-opens=/=ALL-UNNAMED --add-opens=/=ALL-UNNAMED --add-opens=/=ALL-UNNAMED --add-opens=/=ALL-UNNAMED WARNING: Unknown module: specified to --add-opens Exception in thread "main" : java/util/logging/Logger at .<init>(:61) at (:181) at (:130) at (:153) at (:208) at .<clinit>(:50) Caused by: : at /(:636) at /$(:182) at /(:519) ... 6 more
- Right-click the file, open it through Notepad, and add a line after the last line. Type:
pause
。
Save, and then double-click to open the file. At this time, a new Tomcat window will appear, which also has an error message.
Using CATALINA_BASE: "E:\Tomcat\apache-tomcat-8.5.75" Using CATALINA_HOME: "E:\Tomcat\apache-tomcat-8.5.75" Using CATALINA_TMPDIR: "E:\Tomcat\apache-tomcat-8.5.75\temp" Using JRE_HOME: "E:\JAVA\jdk-16.0.2\jre" Using CLASSPATH: "E:\Tomcat\apache-tomcat-8.5.75\bin\;E:\Tomcat\apache-tomcat-8.5.75\bin\" Using CATALINA_OPTS: "" NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=/=ALL-UNNAMED --add-opens=/=ALL-UNNAMED --add-opens=/=ALL-UNNAMED --add-opens=/=ALL-UNNAMED --add-opens=/=ALL-UNNAMED WARNING: Unknown module: specified to --add-opens Exception in thread "main" : java/util/logging/Logger at .<init>(:61) at (:181) at (:130) at (:153) at (:208) at .<clinit>(:50) Caused by: : at /(:636) at /$(:182) at /(:519) ... 6 more
Modify jre environment variables
search
Search by search engineCaused by: :
Discovered: jre's problem.Revise
Right-click to open the file through Notepad, and then modify the code written in the previous step of modifying the source code to
set JAVA_HOME=E:\JAVA\jdk-16.0.2 set JRE_HOME=E:\JAVA\jdk-16.0.2
result
Double-click to open it and found that it can run successfully, but there is a problem with garbled code.
Change the garbled problem
Revise
We come to the conf directory, find a file named , open this configuration file, and modify the following configuration items:
= UTF-8 # Modify to the following code = GBK
After saving, restart tomcat!
result
Congratulations, it was successful.
Remodify environment variables
When I was writing this blog, I found that I was actually configuring the JAVA environment variables incorrectly.
- Should be: JAVA_HOME:E:\JAVA\jdk-16.0.2 Path: %JAVA_HOME%\bin
- What I made: JAVA_HOUME:E:\JAVA\jdk-16.0.2 Path: %JAVA_HOUME%\bin
This leads to an error, but use the cmd command window to enter the following commands:java
、javac
、java -version
None of them have any problems.
After modifying the environment variables, delete the code I wrote in the configuration file:
set JAVA_HOME=E:\JAVA\jdk-16.0.2 set JRE_HOME=E:\JAVA\jdk-16.0.2
Then there is no problem.
The above is the detailed content of solving the problem of Tomcat Caused by: :. For more information about Tomcat Caused, please follow my other related articles!