3

I am creating web application using Embedded Tomcat. I tried to use the latest version 9 (9.0.10), but while the server started, it seemed that it's not running when accessed on browser. Firefox says Unable to connect Firefox can’t establish a connection to the server at localhost:8080.. There were no error logs.

But, when changed the version to 8 (8.5.32), it worked. I also noticed the difference between their console logs:

Tomcat 9.0.10:

Aug 16, 2018 2:19:46 PM org.apache.catalina.core.StandardContext setPath
WARNING: A context path must either be an empty string or start with a '/' and do not end with a '/'. The path [/] does not meet these criteria and has been changed to []
Aug 16, 2018 2:19:47 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Tomcat]
Aug 16, 2018 2:19:47 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/9.0.10
Aug 16, 2018 2:19:47 PM org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment
INFO: No global web.xml found
Aug 16, 2018 2:19:47 PM org.apache.jasper.servlet.TldScanner scanJars
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.

Tomcat 8.5.32:

Aug 16, 2018 2:41:32 PM org.apache.catalina.core.StandardContext setPath
WARNING: A context path must either be an empty string or start with a '/' and do not end with a '/'. The path [/] does not meet these criteria and has been changed to []
Aug 16, 2018 2:41:33 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Aug 16, 2018 2:41:33 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Aug 16, 2018 2:41:33 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Tomcat]
Aug 16, 2018 2:41:33 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.5.32
Aug 16, 2018 2:41:33 PM org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment
INFO: No global web.xml found
Aug 16, 2018 2:41:33 PM org.apache.jasper.servlet.TldScanner scanJars
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.
Aug 16, 2018 2:41:33 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]

Two primary differences I noticed are:

  1. Aug 16, 2018 2:41:33 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector --- I though from version 8 up to the latest, Tomcat is already NIO based as BIO has been removed. But this log only appears on 8
  2. Tomcat 8 displays port the server is running on.

Can anyone help me understand these? Thanks.

Julez
  • 1,010
  • 22
  • 44
  • Did you miss `WARNING: A context path must either be an empty string or start with a '/' and do not end with a '/'. The path [/] does not meet these criteria and has been changed to []` – Jim Garrison Aug 16 '18 at 06:51
  • I know that is a problem and I'll be fixing that. If you can notice both of them have that warning but still their logs are different. The 8 has this NioSelectorPool but 9 does not have. And I am able to open the Tomcat 8 on browser though it has error (Tomcat error). The error of 9 on browser is not of Tomcat but of browser. – Julez Aug 16 '18 at 07:02
  • You're right @OlafKock. Now I understand why the NIO thing does not display. I forgot to mention I also thought that NIO selector has been the default selector and BIO has been removed. It's now working. Thanks. – Julez Aug 16 '18 at 07:22

0 Answers0