gradlenetbeansnetbeans-8gradle-pluginnetbeans-plugins

org.gradle.tooling.GradleConnectionException: Could not fetch model of type 'BuildEnvironment'


I am running netbeans with lates version of Gradle on windows and anytime I try to select an old project from the gradle tasks panel I get the following error:

Requested project: D:\ian\libGDX\MarioBros

Stack trace:
    org.gradle.tooling.GradleConnectionException: Could not fetch model of type 'BuildEnvironment' using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.10-all.zip'.
        at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:55)
        at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)
        at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:41)
        at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.lang.Thread.run(Thread.java:748)
        at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
        at org.gradle.tooling.internal.consumer.DefaultModelBuilder.get(DefaultModelBuilder.java:50)
        at org.netbeans.gradle.project.model.DefaultGradleModelLoader.loadModelWithProgress(DefaultGradleModelLoader.java:551)
        at org.netbeans.gradle.project.model.DefaultGradleModelLoader.access$1600(DefaultGradleModelLoader.java:64)
        at org.netbeans.gradle.project.model.DefaultGradleModelLoader$6.run(DefaultGradleModelLoader.java:419)
        at org.netbeans.gradle.project.tasks.GradleDaemonManager.runNonBlockingGradleTask(GradleDaemonManager.java:35)
        at org.netbeans.gradle.project.tasks.GradleDaemonManager.access$100(GradleDaemonManager.java:22)
        at org.netbeans.gradle.project.tasks.GradleDaemonManager$2.execute(GradleDaemonManager.java:125)
        at org.jtrim.concurrent.AbstractTaskExecutorService$FunctionWrapper.execute(AbstractTaskExecutorService.java:270)
        at org.jtrim.concurrent.AbstractTaskExecutorService$TaskOfAbstractExecutor.execute(AbstractTaskExecutorService.java:340)
        at org.jtrim.concurrent.Tasks$RunOnceCancelableTask.execute(Tasks.java:342)
        at org.jtrim.concurrent.SingleThreadedExecutor$QueuedItem.runTask(SingleThreadedExecutor.java:919)
        at org.jtrim.concurrent.SingleThreadedExecutor$QueuedItem.access$1200(SingleThreadedExecutor.java:898)
        at org.jtrim.concurrent.SingleThreadedExecutor$Impl$Worker.executeTask(SingleThreadedExecutor.java:815)
        at org.jtrim.concurrent.SingleThreadedExecutor$Impl$Worker.processQueue(SingleThreadedExecutor.java:827)
        at org.jtrim.concurrent.SingleThreadedExecutor$Impl$Worker.run(SingleThreadedExecutor.java:861)
        at org.jtrim.concurrent.SingleThreadedExecutor$Impl$1.run(SingleThreadedExecutor.java:453)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: org.gradle.api.GradleException: Java home supplied via 'org.gradle.java.home' is invalid. Invalid directory: C:\Program Files\Java\jdk1.8.0_92
        at org.gradle.launcher.cli.converter.PropertiesToDaemonParametersConverter.convert(PropertiesToDaemonParametersConverter.java:51)
        at org.gradle.tooling.internal.provider.ProviderConnection.initParams(ProviderConnection.java:172)
        at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:91)
        at org.gradle.tooling.internal.provider.DefaultConnection.getModel(DefaultConnection.java:168)
        at org.gradle.tooling.internal.consumer.connection.CancellableModelBuilderBackedModelProducer.produceModel(CancellableModelBuilderBackedModelProducer.java:53)
        at org.gradle.tooling.internal.consumer.connection.PluginClasspathInjectionSupportedCheckModelProducer.produceModel(PluginClasspathInjectionSupportedCheckModelProducer.java:41)
        at org.gradle.tooling.internal.consumer.connection.AbstractConsumerConnection.run(AbstractConsumerConnection.java:58)
        at org.gradle.tooling.internal.consumer.connection.ParameterValidatingConsumerConnection.run(ParameterValidatingConsumerConnection.java:46)
        at org.gradle.tooling.internal.consumer.DefaultModelBuilder$1.run(DefaultModelBuilder.java:60)
        at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:84)
        at org.gradle.tooling.internal.consumer.connection.CancellableConsumerActionExecutor.run(CancellableConsumerActionExecutor.java:45)
        at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58)
        at org.gradle.tooling.internal.consumer.connection.RethrowingErrorsConsumerActionExecutor.run(RethrowingErrorsConsumerActionExecutor.java:38)
        at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        ... 1 more

Has anyone else run into this error? And How to fix the problem?


Solution

  • Actually the issue is described here already

    Caused by: org.gradle.api.GradleException: Java home supplied via 'org.gradle.java.home' is invalid. Invalid directory: C:\Program Files\Java\jdk1.8.0_92
    

    If you go to your gradle.properties configuration file, you will get the following

    org.gradle.java.home=C:\Program Files\Java\jdk1.8.0_92

    You can remove it or give the original JAVA_HOME location. Hope it will solve your issue.

    N.B: If your path is OK, then use double backslashes "\" like above in your path.