How to Fix Tomcat Migrating from 8.5.x to 9.0.x Problems?

Inanc Cakil
2 min readJan 5, 2021

I upgraded my embedded Tomcat version from 8.5.43 to 9.0.38 and I had some problems. If you have problems too maybe this will help you.

First of all, you can check tomcat documentation http://tomcat.apache.org/migration-9.html#Migrating_from_8.0.x_or_8.5.x_to_9.0.x

The documentation didn't help me much and there wasn't any exception or enough information on the log, so first I increased the logging level to see what is wrong.
I created logging.properties file with the highest log level (FINEST).

java.util.logging.ConsoleHandler.level = FINEST
java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter
java.util.logging.ConsoleHandler.encoding = UTF-8
handlers = java.util.logging.ConsoleHandler
org.apache.coyote.http2.level = FINEST
org.apache.catalina.level=FINEST
org.apache.jasper.level = FINEST
log4j.logger.org.apache.catalina=FINEST

and added system property to enable logging.

-Djava.util.logging.config.file=yourpath/logging.properties

or just add this to your code.

System.setProperty(“java.util.logging.config.file”,”yourpath\logging.properties”);

When I compare logs, found that Connector not starting in tomcat 9.

Tomcat 9 no longer automatically adds a Connector to your server for you, so you'll have to trigger it yourself.

adding tomcat.getConnector(); is enough.

Tomcat tomcat = new Tomcat();
tomcat.getConnector(); // Trigger the creation of the default connector

The connector was created but this time tomcat was getting stuck at the startup. Usually, this happens on VM and here is how you can fix this.

I added this to my code.

System.setProperty(“java.security.egd”, “file:/dev/./urandom”);

And this simple trick has helped me, and I hope you too!

--

--