A java application fails to start with classloading error. Tomcat 9 load classes is random and the error occurs when the wrong class/jar gets loaded first.
This KB will provide steps to identify the duplicate classes/jars.
This is usually due to having same class in multiple jar.
To find jar having duplicate classes, you can do the following steps:
$ cd <PATH-webapp>/<APP-NAME>/WEB-INF/lib$ ls *.jar | xargs -n1 -IFILE unzip -l FILE | grep class | sed "s,.* ,," | tr "/" "." | grep -v module-info.class | sort | uniq -d > CLASSES.TXT$ for line in $(cat CLASSES.TXT); do echo -----$line; grep -iRH $line *.jar ; done$ for line in $(cat CLASSES.TXT); do echo -----$line; grep -iRH $line *.jar ; done-----org.springframework.boot.actuate.amqp.RabbitHealthIndicator.classBinary file dup-spring-boot-actuator-2.2.2.RELEASE.jar matchesBinary file spring-boot-actuator-2.2.2.RELEASE.jar matches-----org.springframework.boot.actuate.audit.AuditEvent.classBinary file dup-spring-boot-actuator-2.2.2.RELEASE.jar matchesBinary file spring-boot-actuator-2.2.2.RELEASE.jar matches--
Once you have the duplicate jars you can decide which one to keep/delete. Our recommendation is to delete/remove the unused (or old) jars from the app.