[Java] Talked about Tomcat getting a timeout error in Eclipse

4 minute read

Introduction

This article summarizes the case when there was a case where Tomcat could not be started from Eclipse before. The cause was too blind, so I hope it will be a hint for those who are equally troubled. As the target is for those who are building a development environment, it is for beginners.

environment

OS: macOS Catalina(10.15.5) Eclipse: Eclipse 2020~2018 *We could not identify the cause and dropped about 3 versions

The beginning of things

About 3 months ago I was trying to create a web application using strus2, but it was left for a long time, so I was messing with the flow of making a continuation. (Will to move to maven project because there are many libraries) The POM settings are over, and the server will start in seconds when it’s time to start the server. The server doesn’t start for some reason… For some reason, I got a server timeout error when I waited. Screenshots 2020-06-12 11.05.07.png

Have tried

I thought it was a little unwell, so I changed the server timeout time from 45 seconds to 120 seconds. Still, I get a timeout error. There is nothing particularly suspicious in the log.

Info: Server version: Apache Tomcat/8.5.34 [Fri Jun 12 11:04:07 JST 2020]
Information: Server built: Sep 4 2018 22:28:22 UTC [Fri 6 12 11:04:07 JST 2020]
Information: Server number: 8.5.34.0 [Fri 6 12 11:04:07 JST 2020]
Information: OS Name: Mac OS X [Fri 6 12 11:04:07 JST 2020]
Information: OS Version: 10.15.5 [Fri 6 12 11:04:07 JST 2020]
Information: Architecture: x86_64 [Fri 6 12 11:04:07 JST 2020]
Information: Java Home: /Applications/Eclipse_2018-09.app/Contents/java/8/Home/jre [Fri 6 12 11:04:07 JST 2020]
Information: JVM Version: 1.8.0_181-b13 [Fri 6 12 11:04:07 JST 2020]
Info: JVM Vendor: Oracle Corporation [Fri 6 12 11:04:07 JST 2020]
Information: CATALINA_BASE: /Applications/Eclipse_2018-09.app/Contents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0 [Fri 6 12 11:04:07 JST 2020]
Information: CATALINA_HOME: /Applications/Eclipse_2018-09.app/Contents/tomcat/8 [Fri 6 12 11:04:07 JST 2020]
Information: Command line argument: -Djava.ext.dirs=/Applications/Eclipse_2018-09.app/Contents/java/8/Home/jre/lib/ext [Fri 6 12 11:04:07 JST 2020]
Information: Command line argument: -Dcatalina.base=/Applications/Eclipse_2018-09.app/Contents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0 [Fri 6 12 11:04:07 JST 2020]
Information: Command line argument: -Dcatalina.home=/Applications/Eclipse_2018-09.app/Contents/tomcat/8 [Fri 6 12 11:04:07 JST 2020]
Information: Command line argument: -Dwtp.deploy=/Applications/Eclipse_2018-09.app/Contents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps [Fri 6 12 11:04 :07 JST 2020]
Information: Command line argument: -Djava.endorsed.dirs=/Applications/Eclipse_2018-09.app/Contents/tomcat/8/endorsed [Fri 6 12 11:04:07 JST 2020]
Information: Command line argument: -Dfile.encoding=UTF-8 [Fri 6 12 11:04:07 JST 2020]
Info: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/XXXXXXXX/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library /Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.] [Fri 6 12 11:04:07 JST 2020]
Info: Initializing ProtocolHandler ["http-nio-8080"] [Fri 6 12 11:04:07 JST 2020]
Information: Using a shared selector for servlet write/read [Fri 6 12 11:04:07 JST 2020]
Information: Initializing ProtocolHandler ["ajp-nio-8009"] [Fri 6 12 11:04:07 JST 2020]
Information: Using a shared selector for servlet write/read [Fri 6 12 11:04:07 JST 2020]
Information: Initialization processed in 1147 ms [Fri 6 12 11:04:07 JST 2020]
INFO: Starting service [Catalina] [Fri 6 12 11:04:07 JST 2020]
Info: Starting Servlet Engine: Apache Tomcat/8.5.34 [Fri 6 12 11:04:07 JST 2020]
Info: At least one JAR was scanned for TLDs yet contained no TLDs.Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them.Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. [Fri 6 12 11:04:10 JST 2020]
Info: Starting ProtocolHandler ["http-nio-8080"] [Fri 6 12 11:04:10 JST 2020]
Information: Starting ProtocolHandler ["ajp-nio-8009"] [Fri 6 12 11:04:10 JST 2020]
Info: Server startup in 2956 ms [Fri Jun 12 11:04:10 JST 2020]

Is tomcat not working due to my mavenization from here? I came up with the idea that I once deleted the project. After deleting the project, when checking if only the server will start, a timeout error still occurs. I tried reinserting Eclipse with the feeling that it might have been destroyed from here. Even if I check if only the server is started in the same way, a timeout error still occurs. Both Java version and tomcat version match and the cause is completely unknown. The next thing to do is to check if the server can be started with tomcat alone.

How to install Apache Tomcat on Mac

If you start the server according to the above, it seems that it is starting normally, http://localhost:8080 When I go to connect…

** After all I can not connect! !! !! !! !! !! !! **

MochiMac:bin XXXXX$ ./startup.sh
Using CATALINA_BASE: /Users/XXXXX/Desktop/apache-tomcat-9.0.36
Using CATALINA_HOME: /Users/XXXXX/Desktop/apache-tomcat-9.0.36
Using CATALINA_TMPDIR: /Users/XXXXX/Desktop/apache-tomcat-9.0.36/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
Using CLASSPATH: /Users/XXXXX/Desktop/apache-tomcat-9.0.36/bin/bootstrap.jar: /Users/XXXXX/Desktop/apache-tomcat-9.0.36/bin/tomcat-juli.jar
Tomcat started.

**Starting because it’s displayed as staeted! !! !! !! **

For the first time, I went to check the log, because I was so tired of screaming. (I regret that I should have searched the log even when I started it with eclipse.) Then, for the first time, I touched on the hint of the cause.

12-Jun-2020 09:40:29.349 Info [main] org.apache.coyote.AbstractProtocol.init Initialize the protocol handler ["http-nio-8080"]. 12-Jun-2020 09:40:29.374 Severe [main] org.apache.catalina.util.LifecycleBase.handleSubClassException Component [Connector[HTTP/1.1-8080]] initialization failed. org.apache.catalina.LifecycleException: Protocol handler initialization failed at org.apache.catalina.connector.Connector.initInternal(Connector.java:1042) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) at org.apache.catalina.core.StandardService.initInternal(StandardService.java:533) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:1057) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) at org.apache.catalina.startup.Catalina.load(Catalina.java:584) at org.apache.catalina.startup.Catalina.load(Catalina.java:607)

** Are you using 8080? ** I did not intend to use it, but I thought it was probably used somewhere, so I fixed it to use 8081.

Simple way to change Tomcat port

If you correct it according to the above, you can not connect to 8081 this time. image.png

Why is the connection refused? And after a good memory, I remember that the security software was installed again two months ago… Perhaps if you restart the tomcat with the security software around the firewall and access restrictions disabled…

**moved! !! !! !! !! !! !! You can also connect to localhost:8080! !! !! !! !! **

Furthermore, the server started up safely in Eclipse as it was.

result

So far, the cause was the security software around the firewall and the setting of access restrictions. It’s too stupid, it’s a blind spot, and it took time to identify the cause, so I made it an article.