# Gradle task groovyDoc failing with NoClassDefFoundError

**URL:** <https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541>\
**Category:** Old Forum Archive\
**Created:** [December 16, 2013, 7:51pm UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541 "2013-12-16T19:51:00Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tyler\_Bayne](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@Tyler\_Bayne](https://discuss.gradle.org/u/Tyler_Bayne)\
**Post date:** [December 16, 2013, 7:51pm UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/1 "2013-12-16T19:51:00Z")

</div>

I was originally using Gradle 1.5 to test my Groovy scripts but also tried this with Gradle 1.9 and experienced the same problem. The groovyDoc task in build.gradle is set up like:

```gradle
groovydoc {
    docTitle = "Name"
    windowTitle = "Name"
    destinationDir = file('file://path')
}

```

The error I’m getting when running this task is:

```gradle
FAILURE: Build failed with an exception.
  * What went wrong:
Execution failed for task ':groovydoc'.
> java.lang.NoClassDefFoundError: org/fusesource/jansi/AnsiRenderWriter

```

This only started happening after I made a minor code change (adding a single If statement) to one of my classes. I reverted to the previous commit and it does not have this problem. I tried deleting my change in the class and recommitting the same file but it is still failing.

You can see the full stacktrace here: [http://pastebin.com/1infzqtY](http://pastebin.com/1infzqtY)

---

<div class="post-metadata">

**Author:** ![Tyler\_Bayne](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@Tyler\_Bayne](https://discuss.gradle.org/u/Tyler_Bayne)\
**Post date:** [December 16, 2013, 8:03pm UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/2 "2013-12-16T20:03:00Z")

</div>

I forgot to mention that I do have the jansi-1.2.1.jar in the lib folder of the Gradle installation.

---

<div class="post-metadata">

**Author:** ![Tyler\_Bayne](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@Tyler\_Bayne](https://discuss.gradle.org/u/Tyler_Bayne)\
**Post date:** [January 2, 2014, 5:29pm UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/3 "2014-01-02T17:29:00Z")

</div>

I was able to get it working with help from an answer to my stack overflow post here:

[http://stackoverflow.com/questions/20618857/gradle-task-groovydoc-failing-with-noclassdeffounderror/20862163?noredirect=1#20862163](http://stackoverflow.com/questions/20618857/gradle-task-groovydoc-failing-with-noclassdeffounderror/20862163?noredirect=1#20862163)

The solution is to add the following to the build.gradle file:

```gradle
configurations {
    jansi.extendsFrom(runtime)
}
groovydoc {
    def title = "IPDS ${version}"
    groovyClasspath = project.configurations.jansi
}
dependencies {
    jansi 'org.fusesource.jansi:jansi:1.11'

```

---

<div class="post-metadata">

**Author:** ![Paolo\_Di\_Tommaso](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/paolo_di_tommaso/32/658_2.png) [@Paolo\_Di\_Tommaso](https://discuss.gradle.org/u/Paolo_Di_Tommaso)\
**Post date:** [January 6, 2014, 12:38pm UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/4 "2014-01-06T12:38:00Z")

</div>

When trying the suggested fix in the previous post, it raises another exception in my case

:groovydoc FAILED

FAILURE: Build failed with an exception.

- What went wrong:

Execution failed for task ‘:groovydoc’.

> groovy/util/AntBuilder

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [January 6, 2014, 12:54pm UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/5 "2014-01-06T12:54:00Z")

</div>

Please show the relevant parts of your build script, in particular the declaration of the Groovy dependency. Output of ‘gradle -v’ and stack trace (’–stacktrace’) would also help.

---

<div class="post-metadata">

**Author:** ![Paolo\_Di\_Tommaso](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/paolo_di_tommaso/32/658_2.png) [@Paolo\_Di\_Tommaso](https://discuss.gradle.org/u/Paolo_Di_Tommaso)\
**Post date:** [January 6, 2014, 1:42pm UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/6 "2014-01-06T13:42:00Z")

</div>

Hi there, here it is

allprojects {

apply plugin: ‘groovy’

dependencies {

compile (“org.codehaus.groovy:groovy:${groovyVer}”)

testCompile (“cglib:cglib-nodep:${cglibVer}”)

testCompile (“org.objenesis:objenesis:${objenesisVer}”)

testCompile (“org.spockframework:spock-core:${spockVer}”) {

exclude module: ‘groovy-all’

}

}

}

configurations {

oneJarLib

dnanexus.extendsFrom runtime

jansi.extendsFrom(runtime)

}

dependencies {

compile “org.codehaus.gpars:gpars:${gparsVer}”

compile “org.slf4j:slf4j-api:${slf4jVer}”

compile “org.slf4j:jcl-over-slf4j:${slf4jVer}”

compile “org.slf4j:jul-to-slf4j:${slf4jVer}”

compile “org.slf4j:log4j-over-slf4j:${slf4jVer}”

compile “ch.qos.logback:logback-classic:${logbackVar}”

compile “ch.qos.logback:logback-core:${logbackVar}”

compile “commons-lang:commons-lang:${commonsLangVer}”

compile “commons-io:commons-io:${commonsIoVer}”

compile “com.beust:jcommander:${jcommanderVer}”

compile “com.google.code.findbugs:jsr305:${jsr305Ver}”

oneJarLib files(‘one-jar/one-jar-boot-0.97.jar’)

dnanexus (project(’:dnanexus’)) {

exclude module: ‘nextflow’

}

jansi ‘org.fusesource.jansi:jansi:1.11’

}

groovydoc {

def title = “IPDS ${version}”

groovyClasspath = project.configurations.jansi

}

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [January 6, 2014, 2:04pm UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/7 "2014-01-06T14:04:00Z")

</div>

Your build script declares a ‘groovy’ (rather than a ‘groovy-all’) dependency, which doesn’t include Groovydoc. Therefore, you’ll have to figure out which dependencies are required for Groovydoc, and add them to the ‘jansi’ configuration as well (which I’d rename to ‘groovydoc’). ‘org.codehaus.groovy:groovy-groovydoc’ and ‘org.codehaus.groovy:groovy-ant’ are two candidates.

---

<div class="post-metadata">

**Author:** ![Paolo\_Di\_Tommaso](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/paolo_di_tommaso/32/658_2.png) [@Paolo\_Di\_Tommaso](https://discuss.gradle.org/u/Paolo_Di_Tommaso)\
**Post date:** [January 6, 2014, 6:40pm UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/8 "2014-01-06T18:40:00Z")

</div>

Yes, it solved the problem.

Thanks

---

<div class="post-metadata">

**Author:** ![Russel\_Winder](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/russel_winder/32/367_2.png) [@Russel\_Winder](https://discuss.gradle.org/u/Russel_Winder)\
**Post date:** [August 31, 2014, 10:05am UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/9 "2014-08-31T10:05:00Z")

</div>

GPars (and GroovyFX) have just come up against this problem. Our workaround is slightly different to the above but equally ugly. The core question here is why the default Gradle groovydoc task does not include all the necessary dependencies by default.

This is with Gradle 2.0.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [August 31, 2014, 2:20pm UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/10 "2014-08-31T14:20:00Z")

</div>

‘GroovyCompile’ and ‘Groovydoc’ use whatever Groovy dependencies are put on the ‘compile’ configuration. Easiest solution is to use ‘groovy-all’.

---

<div class="post-metadata">

**Author:** ![Russel\_Winder](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/russel_winder/32/367_2.png) [@Russel\_Winder](https://discuss.gradle.org/u/Russel_Winder)\
**Post date:** [August 31, 2014, 4:56pm UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/11 "2014-08-31T16:56:00Z")

</div>

We definitely depend on groovy-all in the compile configuration. I am having to add ‘org.fusesource.jansi:jansi:1.11’ manually, which I shouldn’t have to. This strikes me as a transitive dependency failure somewhere. I guess the could be in the groovy-all POM if it isn’t a Gradle dependency tracking failure. If this is the case, the issue report should really come from the Gradle team I think.

Of course this assumes I am not doing something very silly in the GPars and GroovyFX builds…

---

<div class="post-metadata">

**Author:** ![msgilligan](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/msgilligan/32/137_2.png) [@msgilligan](https://discuss.gradle.org/u/msgilligan)\
**Post date:** [September 25, 2014, 11:27pm UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/12 "2014-09-25T23:27:00Z")

</div>

I’m seeing the same issue in a build file of mine and groovy-all is in the compile configuration.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [September 25, 2014, 11:45pm UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/13 "2014-09-25T23:45:00Z")

</div>

Any chance you can provide a minimal self-contained reproducible example? I’ve been using the ‘Groovydoc’ task with a wide range of ‘groovy-all’ versions, and have never had an issue.

---

<div class="post-metadata">

**Author:** ![msgilligan](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/msgilligan/32/137_2.png) [@msgilligan](https://discuss.gradle.org/u/msgilligan)\
**Post date:** [September 26, 2014, 12:30am UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/14 "2014-09-26T00:30:00Z")

</div>

git clone [https://github.com/msgilligan/bitcoin-spock.git](https://github.com/msgilligan/bitcoin-spock.git) ./gradlew groovydoc

---

<div class="post-metadata">

**Author:** ![msgilligan](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/msgilligan/32/137_2.png) [@msgilligan](https://discuss.gradle.org/u/msgilligan)\
**Post date:** [September 26, 2014, 12:34am UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/15 "2014-09-26T00:34:00Z")

</div>

I’m not sure what could have changed to cause this to fail after it had been working. Either: 1) Bumping Groovy from 2.3.5 to 2.3.6: [https://github.com/msgilligan/bitcoin-spock/commit/b81a5df30636c5bbbe326e5c59dc18431065334b](https://github.com/msgilligan/bitcoin-spock/commit/b81a5df30636c5bbbe326e5c59dc18431065334b) 2) Something changing with spock-core:1.0-groovy-2.3-SNAPSHOT which is the only snapshot dependency in build.gradle

---

<div class="post-metadata">

**Author:** ![msgilligan](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/msgilligan/32/137_2.png) [@msgilligan](https://discuss.gradle.org/u/msgilligan)\
**Post date:** [September 26, 2014, 12:41am UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/16 "2014-09-26T00:41:00Z")

</div>

I’m stripping things down now to see what happens…

---

<div class="post-metadata">

**Author:** ![msgilligan](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/msgilligan/32/137_2.png) [@msgilligan](https://discuss.gradle.org/u/msgilligan)\
**Post date:** [September 26, 2014, 12:48am UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/17 "2014-09-26T00:48:00Z")

</div>

Commenting out the following line makes the error message go away: source = sourceSets.main.groovy + sourceSets.main.java

---

<div class="post-metadata">

**Author:** ![msgilligan](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/msgilligan/32/137_2.png) [@msgilligan](https://discuss.gradle.org/u/msgilligan)\
**Post date:** [September 26, 2014, 4:43am UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/18 "2014-09-26T04:43:00Z")

</div>

Don’t know if I’m spamming Russel by commenting under his post. I’m going to start a new one.

---

<div class="post-metadata">

**Author:** ![msgilligan](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/msgilligan/32/137_2.png) [@msgilligan](https://discuss.gradle.org/u/msgilligan)\
**Post date:** [September 26, 2014, 4:44am UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/19 "2014-09-26T04:44:00Z")

</div>

I’ve stripped down my project even further and the problem is being caused by Java multi catch statements.

---

<div class="post-metadata">

**Author:** ![msgilligan](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/msgilligan/32/137_2.png) [@msgilligan](https://discuss.gradle.org/u/msgilligan)\
**Post date:** [September 26, 2014, 4:45am UTC](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541/20 "2014-09-26T04:45:00Z")

</div>

I also noticed the following error message a few lines up in the output:

[ant:groovydoc] line 37:35: expecting IDENT, found ‘|’

[Next page](https://discuss.gradle.org/t/gradle-task-groovydoc-failing-with-noclassdeffounderror/2541.md?page=2)
