Gradle wrapper fails with NullPointer Exception

Hi,

gradlew fails on my TeamCity agent with the following error:

D:\TeamCity\buildAgent2\work\f143a7864defc8db>.\gradlew.bat tasks Downloading https://binaries.domain.local/artifactory/external-libs/gradle/gradle/

Exception in thread “main” java.lang.NullPointerException

at org.gradle.wrapper.Install.listDirs(Install.java:92)

at org.gradle.wrapper.Install.access$200(Install.java:26)

at org.gradle.wrapper.Install$1.call(Install.java:61)

at org.gradle.wrapper.Install$1.call(Install.java:44)

at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)

at org.gradle.wrapper.Install.createDist(Install.java:44)

at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)

at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:56)

Here’s the gradle-wrapper.properties:

distributionBase=PROJECT

distributionPath=wrapper/dists

zipStoreBase=PROJECT

zipStorePath=wrapper/dists

distributionUrl=https://binaries.domain.local/artifactory/external-libs/gradle/gradle/2.1/gradle-2.1-bin.zip

Gradle version is 2.1.

Any ideas what could be causing this? Thanks!

I had a look around the code and it looks like listing files of the directory into which you are trying to install the distribution returns null and the NullPointerExceptions occurs. This might happen when there is a failure in the native JDK code providing the list of files. I can see that you are on Windows. Is it possible that the user running the command doesn’t have rights to list files in the distribution directory?