How to fix a "Caused by: java.util.ServiceConfigurationError: org.apache.juli.logging.Log: org.eclipse.jetty.apache.jsp.JuliLog not a subtype" error in Jetty

Originally posted on 2020-10-27

I've been doing a bunch of GWT development and testing lately and everything was working fine until I tried to start my local development environment and I ran into this exception:

Caused by: java.util.ServiceConfigurationError: org.apache.juli.logging.Log: org.eclipse.jetty.apache.jsp.JuliLog not a subtype

And Jetty simply gave me a 503 when I tried to connect to it. Bummer.

After a bunch of research I found that this is due to some Tomcat classes being included in my project from another dependency. I opened IntelliJ, tracked down one of the classes to get the exact dependency name, and then added this to my build.gradle.kts file:

NOTE: This is the Kotlin DSL for Gradle! The equivalent Groovy code will be different!

configurations.compile {
    // Fixes - Caused by: java.util.ServiceConfigurationError: org.apache.juli.logging.Log: org.eclipse.jetty.apache.jsp.JuliLog not a subtype
    exclude("org.mortbay.jasper")
}

I like to always put a comment in there to signal why something was included or excluded to make sure I don't mess with it later.