Gradle classloader problems with Jetty plugin

(Christopher Molozian) #1

This problem manifested itself during resolution of a different problem when upgrading to Gradle 1.0M6 from 1.0M3. I’m using a templating engine called Thymeleaf ( in a webapp. The templating engine has an optional dependency on NekoHTML that in turn depends on Xerces XML parser. I’m not using this dependency.

When I run the webapp using the ‘jettyRun’ task I get the following exception:

java.lang.NoClassDefFoundError: org/apache/xerces/parsers/DOMParser
 at java.lang.ClassLoader.defineClass1(Native Method)
 at java.lang.ClassLoader.defineClassCond(
 at java.lang.ClassLoader.defineClass(
 at Method)
 at java.lang.ClassLoader.loadClass(
 at java.lang.ClassLoader.loadClass(
 at org.gradle.util.MultiParentClassLoader.loadClass(
 at java.lang.ClassLoader.loadClass(
 at java.lang.ClassLoader.loadClass(
 at java.lang.ClassLoader.loadClass(
 at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(
 at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(
 at org.thymeleaf.TemplateParser.computeIsNekoInClassPath(
 at org.thymeleaf.TemplateParser.<init>(
 at org.thymeleaf.TemplateEngine.initialize(
 at org.thymeleaf.TemplateEngine.process(
 at org.thymeleaf.spring3.view.ThymeleafView.render(

This is because the ‘org.thymeleaf.TemplateParser’ attempts to find nekohtml on the classpath using the method: ‘computeIsNekoInClassPath()’ which calls:

try {
    return true;
} catch (ClassNotFoundException e) {
    return false;

This call appears to have problems computing the classpath with the ‘org.gradle.util.MultiParentClassLoader.loadClass()’ method. I’ve attached a full example project that reproduces the error consistently here:

Any and all help is appreciated.

(Christopher Molozian) #2

There’s really not much more information I can provide… I built the latest Gradle 1.0M7 release from the master branch on the git repository. The problem still exists on there as well.

(Nadav) #3

I ran into the same problem… have you managed to work around this?

(Christopher Molozian) #4

Hey Nadav,

Unfortunately I never found a workaround for it, I had to start using the Jetty Runner ( project to spin up a quick Java web server during development. I did open an issue on the Gradle Issue Tracker here:

But ever since I’ve opened the issue, it’s scheduled fix version has been bumped by the Gradle developers.

(Nadav) #5


Got good news from the good folks of Thymeleaf - they’ve solved this issue for their next version.

See this link for details:

(Christopher Molozian) #6

Hey Nadav,

Thanks very much for the link and the update on the issue. I’ve been using Gradle for quite a while (since 0.7 days) and originally the project worked fine. As the build tool matured they added parallisation of builds, this is when the classloading issues began to occur. I’d assumed that it was a strange classloading bug introduced by Gradle that caused this problem.

I’ve added the Sonatype Snapshot Repository to my build environment and have tested Thymeleaf 2.0.11-SNAPSHOT with success while using the Jetty plugin.

Thanks for your help.