SoFunction
Updated on 2025-03-03

Tomcat startup prompt Couldn't get host name problem

Tomcat startup prompt Couldn't get host name

Problem description

The system can run normally before. After the update, the following error is reported by starting tomcat:

2020-07-31 17:21:39 [main] INFO   - Using default implementation for ThreadExecutor
2020-07-31 17:21:39 [main] ERROR - Couldn't generate instance Id!
: Couldn't get host name!
    at (:36)
    at (:1235)
    at (:1559)
    at (:637)
    at (:511)
    at (:1765)
    at (:1702)
    at (:579)
    at (:501)
    at $doGetBean$0(:317)
    at (:228)
    at (:315)
    at (:199)
    at (:251)
    at (:1138)
    at (:1065)
    at $(:584)
    at (:91)
    at (:373)
    at (:1348)
    at (:578)
    at (:501)
    at $doGetBean$0(:317)
    at (:228)
    at (:315)
    at (:204)
    at (:238)
    at (:710)
    at (:535)
    at (:140)
    at (:759)
    at (:395)
    at (:327)
    at (:155)
    at (:135)
    at (:87)
    at (:172)
    at (:5125)
    at (:183)
    at (:713)
    at (:690)
    at (:695)
    at (:978)
    at $(:1850)
    at $(:511)
    at (:266)
    at (:75)
    at (:112)
    at (:773)
    at (:427)
    at (:1577)
    at (:309)
    at (:123)
    at (:424)
    at (:367)
    at (:929)
    at (:831)
    at (:183)
    at $(:1377)
    at $(:1367)
    at (:266)
    at (:75)
    at (:134)
    at (:902)
    at (:262)
    at (:183)
    at (:423)
    at (:183)
    at (:928)
    at (:183)
    at (:638)
    at .invoke0(Native Method)
    at (:62)
    at (:43)
    at (:498)
    at (:350)
    at (:492)
Caused by: : xxxxx: xxxxx: Name or service not known
    at (:1506)
    at (:34)
    ... 76 common frames omitted
Caused by: : xxxxx: Name or service not known
    at .(Native Method)
    at $(:929)
    at (:1324)
    at (:1501)
    ... 77 common frames omitted

Solution

As shown in the exception message, Couldn't get host name!, xxxxx: Name or service not known, it can be inferred that the hostname xxxxx cannot be parsed. Open the /etc/hosts file, and the domain name is not parsed. Add a line of domain name resolution: 127.0.0.1 xxxxx

save

Then restart tomcat and it will start normally

Later, I confirmed with the operation and maintenance staff that they did adjust the server information in the middle, which led to the hostname resolution exception. .

Resolving some startup errors about Tomcat

1. Eclipse tomcat startup timeout

Error content: Server JBoss v4.0 at localhost was unable to start within 50 seconds. If the server requires more time, try increasing the timeout in the server editor

Solution: Modify the path

Enter Eclipse's workspace .\directory and modify the files in the directory

Find start-timeout=”45” and set high start-timeout=”450”

2. Eclipse cannot load tomcat

Error content: After deleting tomcat, re-import tomcat, but tomcat cannot be loaded

Solution:

1. Exit eclipse

2. Go to [Project Directory]/.metadata/.plugins/

3. Remove these two files

4. Restart eclipse

3. Tomcat run does not generate class files

Error content: The project compiled without production class file

Solution:

1. Select: project->clean..->Select the second clean select project, and check start build immediately

2. If an unused jar package is introduced in the project and the package is deleted by you, there will be no error but the class file cannot be compiled. You can delete all the packages and then introduce them one by one (needed). Do not introduce all the packages at once. Uselessness may cause adverse consequences.

Steps: Select the project - right click - Properties - select the red area below - select the Jar package inside - click remover

3. Delete the current project, set the compiled file output path in advance, re-import the source file, set MyEclipse to compile when saving, and then it can be automatically compiled when saving. Steps: Select the project->right click Properties->java build path->source->…/WEB-INF/src output folder do not default, edit it and point it to.../WEB-INF/classes

4. The most important thing is to see if the work directory is missing under the project. Since the work is not added as the version during CVS control, there is no such directory after checkout. Some projects need to be added manually to automatically compile. At the beginning, I only found the first 7 methods, but they did not solve my problem. I accidentally opened the "Problems" tag and found that it said that the work directory is missing. I manually added it, and then refresh the project.. The classpath xml file needs to be carefully read.

4. Tomcat startup report PermGen space

Error content: Memory overflow

Solution 1:

1. Restart tomcat

2. First stop running, double-click tomcat, open Open launch configuration, and then add - Xms256M -Xmx1024M -XX:PermSize=64M -XX:MaxPermSize=128M, just restart.

Solution 2: Set up Default VM Arguments, open myeclipse—>windows—>preferences—>java—installed JREs
—>Click the JDK you are using—>Edit—>Default VM Arguments Enter -Xms64m -Xmx256m

5. Tomcat start report Address already in use: JVM_Bind”

Error content: Port 8005 is occupied

Solution 1 (recommended), modify tomcat/conf/file

Open

Change 8005 in <Server port="8005" shutdown="SHUTDOWN"> to an infrequently used port number, such as 9876

Solution 2: Forced end of the process that occupies 8005

(1) Enter CMD in Run

(2) Enter netstat -ano in the startup window to see the usage of all ports and record the PID of the program that occupies port 8005.

(3) Open "Task Manager", click "View" in the menu bar, then click "Select Column", select "PID (Process Identifier)" or enter the tasklist command in cmd, enter Enter, view

(4) Find the corresponding PID value in the process and end the process

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.