Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javaToolchains task provides insufficient error information #15918

Closed
msgilligan opened this issue Jan 22, 2021 · 6 comments · Fixed by #20814
Closed

javaToolchains task provides insufficient error information #15918

msgilligan opened this issue Jan 22, 2021 · 6 comments · Fixed by #20814
Assignees
Labels
a:bug in:toolchains Java Toolchains
Milestone

Comments

@msgilligan
Copy link

When I run (Windows, PowerShell)

 .\gradlew javaToolchains '-Porg.gradle.java.installations.paths=C:/Program Files/Java/jdk-16-ea-33' --info --stacktrace 

I get the error message

Error:   A problem occurred starting process 'command 'C:\Program Files\Java\jdk-16-ea-33\bin\java.exe''

but I don't get information specific enough to resolve the problem. Note that I can run C:\Program Files\Java\jdk-16-ea-33\bin\java.exe' successfully from the command-line.

Expected Behavior

I expect to see the exact error that is occurring when java.exe is executed.

Current Behavior

Initialized native services in: C:\Users\User\.gradle\native
The client will now receive all logging from the daemon (pid: 460). The daemon log file: C:\Users\User\.gradle\daemon\6.8\daemon-460.out.log
Starting 47th build in daemon [uptime: 1 hrs 36 mins 49.329 secs, performance: 98%, non-heap usage: 28% of 256 MiB]
Using 2 worker leases.
Watching the file system is disabled
Starting Build
Settings evaluated using settings file 'C:\Users\User\git\SupernautFX\settings.gradle'.
Projects loaded. Root project using build file 'C:\Users\User\git\SupernautFX\build.gradle'.
Included projects: [root project 'SupernautFX', project ':supernaut', project ':supernaut-fx', project ':supernaut-fx-micronaut', project ':supernaut-fx-sample-hello', project ':supernaut-fx-sample-minimal', project ':supernaut-fx-testapp']

> Configure project :buildSrc
Evaluating project ':buildSrc' using build file 'C:\Users\User\git\SupernautFX\buildSrc\build.gradle'.
Selected primary task 'build' from project :
:buildSrc:compileJava (Thread[Daemon worker Thread 16,5,main]) started.

> Task :buildSrc:compileJava NO-SOURCE
file or directory 'C:\Users\User\git\SupernautFX\buildSrc\src\main\java', not found
Skipping task ':buildSrc:compileJava' as it has no source files and no previous output files.
:buildSrc:compileJava (Thread[Daemon worker Thread 16,5,main]) completed. Took 0.007 secs.
:buildSrc:compileGroovy (Thread[Execution worker for ':buildSrc',5,main]) started.

> Task :buildSrc:compileGroovy UP-TO-DATE
Caching disabled for task ':buildSrc:compileGroovy' because:
  Build cache is disabled
Skipping task ':buildSrc:compileGroovy' as it is up-to-date.
:buildSrc:compileGroovy (Thread[Execution worker for ':buildSrc',5,main]) completed. Took 0.038 secs.
:buildSrc:processResources (Thread[Daemon worker Thread 16,5,main]) started.

> Task :buildSrc:processResources NO-SOURCE
file or directory 'C:\Users\User\git\SupernautFX\buildSrc\src\main\resources', not found
Skipping task ':buildSrc:processResources' as it has no source files and no previous output files.
:buildSrc:processResources (Thread[Daemon worker Thread 16,5,main]) completed. Took 0.0 secs.
:buildSrc:classes (Thread[Daemon worker Thread 16,5,main]) started.

> Task :buildSrc:classes UP-TO-DATE
Skipping task ':buildSrc:classes' as it has no actions.
:buildSrc:classes (Thread[Daemon worker Thread 16,5,main]) completed. Took 0.0 secs.
:buildSrc:jar (Thread[Daemon worker Thread 16,5,main]) started.

> Task :buildSrc:jar UP-TO-DATE
file or directory 'C:\Users\User\git\SupernautFX\buildSrc\build\classes\java\main', not found
Caching disabled for task ':buildSrc:jar' because:
  Build cache is disabled
  Caching has not been enabled for the task
Skipping task ':buildSrc:jar' as it is up-to-date.
:buildSrc:jar (Thread[Daemon worker Thread 16,5,main]) completed. Took 0.005 secs.
:buildSrc:assemble (Thread[Daemon worker Thread 16,5,main]) started.

> Task :buildSrc:assemble UP-TO-DATE
Skipping task ':buildSrc:assemble' as it has no actions.
:buildSrc:assemble (Thread[Daemon worker Thread 16,5,main]) completed. Took 0.0 secs.
:buildSrc:compileTestJava (Thread[Daemon worker Thread 16,5,main]) started.

> Task :buildSrc:compileTestJava NO-SOURCE
file or directory 'C:\Users\User\git\SupernautFX\buildSrc\src\test\java', not found
Skipping task ':buildSrc:compileTestJava' as it has no source files and no previous output files.
:buildSrc:compileTestJava (Thread[Daemon worker Thread 16,5,main]) completed. Took 0.001 secs.
:buildSrc:compileTestGroovy (Thread[Daemon worker Thread 16,5,main]) started.

> Task :buildSrc:compileTestGroovy NO-SOURCE
file or directory 'C:\Users\User\git\SupernautFX\buildSrc\src\test\groovy', not found
Skipping task ':buildSrc:compileTestGroovy' as it has no source files and no previous output files.
:buildSrc:compileTestGroovy (Thread[Daemon worker Thread 16,5,main]) completed. Took 0.0 secs.
:buildSrc:processTestResources (Thread[Daemon worker Thread 16,5,main]) started.

> Task :buildSrc:processTestResources NO-SOURCE
file or directory 'C:\Users\User\git\SupernautFX\buildSrc\src\test\resources', not found
Skipping task ':buildSrc:processTestResources' as it has no source files and no previous output files.
:buildSrc:processTestResources (Thread[Daemon worker Thread 16,5,main]) completed. Took 0.0 secs.
:buildSrc:testClasses (Thread[Daemon worker Thread 16,5,main]) started.

> Task :buildSrc:testClasses UP-TO-DATE
Skipping task ':buildSrc:testClasses' as it has no actions.
:buildSrc:testClasses (Thread[Daemon worker Thread 16,5,main]) completed. Took 0.0 secs.
:buildSrc:test (Thread[Daemon worker Thread 16,5,main]) started.

> Task :buildSrc:test NO-SOURCE
file or directory 'C:\Users\User\git\SupernautFX\buildSrc\build\classes\java\test', not found
file or directory 'C:\Users\User\git\SupernautFX\buildSrc\build\classes\groovy\test', not found
Skipping task ':buildSrc:test' as it has no source files and no previous output files.
:buildSrc:test (Thread[Daemon worker Thread 16,5,main]) completed. Took 0.0 secs.
:buildSrc:check (Thread[Daemon worker Thread 16,5,main]) started.

> Task :buildSrc:check UP-TO-DATE
Skipping task ':buildSrc:check' as it has no actions.
:buildSrc:check (Thread[Daemon worker Thread 16,5,main]) completed. Took 0.0 secs.
:buildSrc:build (Thread[Daemon worker Thread 16,5,main]) started.

> Task :buildSrc:build UP-TO-DATE
Skipping task ':buildSrc:build' as it has no actions.
:buildSrc:build (Thread[Daemon worker Thread 16,5,main]) completed. Took 0.0 secs.

> Configure project :
Evaluating root project 'SupernautFX' using build file 'C:\Users\User\git\SupernautFX\build.gradle'.
Configuring signAndPublish task for project :
rootProject.ext.signJPackageImages = false
Adding license extension
Adding licenseMain task for sourceSet main
Adding licenseTest task for sourceSet test
Applying license defaults to task: :licenseFormatMain
Applying license defaults to task: :licenseFormatTest
Applying license defaults to task: :licenseMain
Applying license defaults to task: :licenseTest
Adding download licenses extension
Applying defaults to download task: :downloadLicenses
Adding license extension
Adding licenseMain task for sourceSet main
Adding licenseTest task for sourceSet test
Applying license defaults to task: :supernaut:licenseFormatMain
Applying license defaults to task: :supernaut:licenseFormatTest
Applying license defaults to task: :supernaut:licenseMain
Applying license defaults to task: :supernaut:licenseTest
Adding download licenses extension
Applying defaults to download task: :supernaut:downloadLicenses
Adding license extension
Adding licenseMain task for sourceSet main
Adding licenseTest task for sourceSet test
Applying license defaults to task: :supernaut-fx:licenseFormatMain
Applying license defaults to task: :supernaut-fx:licenseFormatTest
Applying license defaults to task: :supernaut-fx:licenseMain
Applying license defaults to task: :supernaut-fx:licenseTest
Adding download licenses extension
Applying defaults to download task: :supernaut-fx:downloadLicenses
Adding license extension
Adding licenseMain task for sourceSet main
Adding licenseTest task for sourceSet test
Applying license defaults to task: :supernaut-fx-micronaut:licenseFormatMain
Applying license defaults to task: :supernaut-fx-micronaut:licenseFormatTest
Applying license defaults to task: :supernaut-fx-micronaut:licenseMain
Applying license defaults to task: :supernaut-fx-micronaut:licenseTest
Adding download licenses extension
Applying defaults to download task: :supernaut-fx-micronaut:downloadLicenses
Adding license extension
Adding licenseMain task for sourceSet main
Adding licenseTest task for sourceSet test
Applying license defaults to task: :supernaut-fx-sample-hello:licenseFormatMain
Applying license defaults to task: :supernaut-fx-sample-hello:licenseFormatTest
Applying license defaults to task: :supernaut-fx-sample-hello:licenseMain
Applying license defaults to task: :supernaut-fx-sample-hello:licenseTest
Adding download licenses extension
Applying defaults to download task: :supernaut-fx-sample-hello:downloadLicenses
Adding license extension
Adding licenseMain task for sourceSet main
Adding licenseTest task for sourceSet test
Applying license defaults to task: :supernaut-fx-sample-minimal:licenseFormatMain
Applying license defaults to task: :supernaut-fx-sample-minimal:licenseFormatTest
Applying license defaults to task: :supernaut-fx-sample-minimal:licenseMain
Applying license defaults to task: :supernaut-fx-sample-minimal:licenseTest
Adding download licenses extension
Applying defaults to download task: :supernaut-fx-sample-minimal:downloadLicenses
Adding license extension
Adding licenseMain task for sourceSet main
Adding licenseTest task for sourceSet test
Applying license defaults to task: :supernaut-fx-testapp:licenseFormatMain
Applying license defaults to task: :supernaut-fx-testapp:licenseFormatTest
Applying license defaults to task: :supernaut-fx-testapp:licenseMain
Applying license defaults to task: :supernaut-fx-testapp:licenseTest
Adding download licenses extension
Applying defaults to download task: :supernaut-fx-testapp:downloadLicenses

> Configure project :supernaut
Evaluating project ':supernaut' using build file 'C:\Users\User\git\SupernautFX\supernaut\build.gradle'.

> Configure project :supernaut-fx
Evaluating project ':supernaut-fx' using build file 'C:\Users\User\git\SupernautFX\supernaut-fx\build.gradle'.

> Configure project :supernaut-fx-micronaut
Evaluating project ':supernaut-fx-micronaut' using build file 'C:\Users\User\git\SupernautFX\supernaut-fx-micronaut\build.gradle'.
Project :supernaut-fx-micronaut => 'app.supernaut.fx.micronaut' Java module
file or directory 'C:\Users\User\git\SupernautFX\supernaut-fx-micronaut\src\main\groovy', not found
file or directory 'C:\Users\User\git\SupernautFX\supernaut-fx-micronaut\src\main\groovy', not found

> Configure project :supernaut-fx-sample-hello
Evaluating project ':supernaut-fx-sample-hello' using build file 'C:\Users\User\git\SupernautFX\supernaut-fx-sample-hello\build.gradle'.
Project :supernaut-fx-sample-hello => 'app.supernaut.fx.sample.hello' Java module
------------------------------------------------------------------------
Detecting the operating system and CPU architecture
------------------------------------------------------------------------
os.detected.name=windows
os.detected.arch=x86_64
os.detected.version=10.0
os.detected.version.major=10
os.detected.version.minor=0
os.detected.classifier=windows-x86_64
file or directory 'C:\Users\User\git\SupernautFX\supernaut-fx-sample-hello\src\main\groovy', not found
file or directory 'C:\Users\User\git\SupernautFX\supernaut-fx-sample-hello\src\main\groovy', not found

> Configure project :supernaut-fx-sample-minimal
Evaluating project ':supernaut-fx-sample-minimal' using build file 'C:\Users\User\git\SupernautFX\supernaut-fx-sample-minimal\build.gradle'.
Project :supernaut-fx-sample-minimal => 'app.supernaut.fx.sample.minimal' Java module
------------------------------------------------------------------------
Detecting the operating system and CPU architecture
------------------------------------------------------------------------
os.detected.name=windows
os.detected.arch=x86_64
os.detected.version=10.0
os.detected.version.major=10
os.detected.version.minor=0
os.detected.classifier=windows-x86_64
file or directory 'C:\Users\User\git\SupernautFX\supernaut-fx-sample-minimal\src\main\groovy', not found
file or directory 'C:\Users\User\git\SupernautFX\supernaut-fx-sample-minimal\src\main\groovy', not found

> Configure project :supernaut-fx-testapp
Evaluating project ':supernaut-fx-testapp' using build file 'C:\Users\User\git\SupernautFX\supernaut-fx-testapp\build.gradle'.
Project :supernaut-fx-testapp => 'app.supernaut.fx.testapp' Java module
------------------------------------------------------------------------
Detecting the operating system and CPU architecture
------------------------------------------------------------------------
os.detected.name=windows
os.detected.arch=x86_64
os.detected.version=10.0
os.detected.version.major=10
os.detected.version.minor=0
os.detected.classifier=windows-x86_64
file or directory 'C:\Users\User\git\SupernautFX\supernaut-fx-testapp\src\main\groovy', not found
file or directory 'C:\Users\User\git\SupernautFX\supernaut-fx-testapp\src\main\groovy', not found
All projects evaluated.
Selected primary task 'javaToolchains' from project :
Tasks to be executed: [task ':javaToolchains']
Tasks that were excluded: []
:javaToolchains (Thread[Execution worker for ':',5,main]) started.

> Task :javaToolchains
Caching disabled for task ':javaToolchains' because:
  Build cache is disabled
  Caching has not been enabled for the task
Task ':javaToolchains' is not up-to-date because:
  Task.upToDateWhen is false.

 + Options
     | Auto-detection:     Enabled
     | Auto-download:      Enabled

 + AdoptOpenJDK 15.0.2
     | Location:           C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot
     | Language Version:   15
     | Vendor:             AdoptOpenJDK
     | Is JDK:             true
     | Detected by:        Windows Registry

 + Invalid toolchains
     + C:\Program Files\Java\jdk-16-ea-33
       | Error:              A problem occurred starting process 'command 'C:\Program Files\Java\jdk-16-ea-33\bin\java.exe''

:javaToolchains (Thread[Execution worker for ':',5,main]) completed. Took 0.005 secs.

BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed

Context

I'm trying to debug the correct installation and configuration (via -P) of the java toolchain.

Steps to Reproduce

This isn't really feasible -- I suspect the problem may be a permissions/configuration issue on Windows.

Your Environment

Build scan URL: https://gradle.com/s/buqlt74asquvq

@ljacomet
Copy link
Member

Do you get a stacktrace with -s?
If not, could you try compiling Java code with that toolchain and use -s in the command line?

@msgilligan
Copy link
Author

I'll give that a try.

But you do agree that the javaToolchains command should provide more information for why an invalid toolchain is invalid?

@msgilligan
Copy link
Author

msgilligan commented Jan 26, 2021

OK, I ran it again with -s and compileJava. What happens is the invalid toolchain is ignored (with no information provided as to why it is ignored) and then Gradle tries to download JDK 16 (which of course it can't because JDK 16 is only available as Early Access) and the stack trace is for the failure to load JDK 16:

Caused by: org.gradle.api.resources.MissingResourceException: Unable to download toolchain. This might indicate that the combination (version, architecture, release/early access, ...) for the requested JDK is not available.
        at org.gradle.jvm.toolchain.install.internal.AdoptOpenJdkDownloader.download(AdoptOpenJdkDownloader.java:59)
        at org.gradle.jvm.toolchain.install.internal.AdoptOpenJdkRemoteBinary.download(AdoptOpenJdkRemoteBinary.java:54)
        at org.gradle.jvm.toolchain.install.internal.DefaultJavaToolchainProvisioningService.provisionJdk(DefaultJavaToolchainProvisioningService.java:92)
        at org.gradle.jvm.toolchain.install.internal.DefaultJavaToolchainProvisioningService.lambda$provisionInstallation$0(DefaultJavaToolchainProvisioningService.java:78)
        at org.gradle.jvm.toolchain.install.internal.DefaultJavaToolchainProvisioningService$ToolchainProvisioningBuildOperation.call(DefaultJavaToolchainProvisioningService.java:116)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
        at org.gradle.jvm.toolchain.install.internal.DefaultJavaToolchainProvisioningService.wrapInOperation(DefaultJavaToolchainProvisioningService.java:102)
        at org.gradle.jvm.toolchain.install.internal.DefaultJavaToolchainProvisioningService.provisionInstallation(DefaultJavaToolchainProvisioningService.java:76)
        ... 182 more
Caused by: org.gradle.api.resources.MissingResourceException: Could not read 'https://api.adoptopenjdk.net/v3/binary/latest/16/ga/windows/x64/jdk/hotspot/normal/adoptopenjdk' as it does not exist.
        at org.gradle.internal.resource.ResourceExceptions.getMissing(ResourceExceptions.java:53)
        at org.gradle.internal.resource.transfer.AccessorBackedExternalResource.withContent(AccessorBackedExternalResource.java:155)
        at org.gradle.internal.resource.BuildOperationFiringExternalResourceDecorator$7.call(BuildOperationFiringExternalResourceDecorator.java:175)
        at org.gradle.internal.resource.BuildOperationFiringExternalResourceDecorator$7.call(BuildOperationFiringExternalResourceDecorator.java:167)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.resource.BuildOperationFiringExternalResourceDecorator.withContent(BuildOperationFiringExternalResourceDecorator.java:167)
        at org.gradle.jvm.toolchain.install.internal.AdoptOpenJdkDownloader.downloadResource(AdoptOpenJdkDownloader.java:79)
        at org.gradle.jvm.toolchain.install.internal.AdoptOpenJdkDownloader.download(AdoptOpenJdkDownloader.java:57)
        ... 198 more

Build scan is here: https://scans.gradle.com/s/3noqksvu4xfay

@msgilligan
Copy link
Author

msgilligan commented Jan 26, 2021

I manually reinstalled JDK 16 EA 33 and it seems to be working now. I suspect the problem was some kind of Windows permission error, but it would be very helpful if Gradle could log/output information about which test is failing when it determines the JDK path is invalid.

(and, even better, it would be cool if Gradle could download EA builds of the JDK...)

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added the stale label Apr 16, 2022
@ljacomet ljacomet removed the stale label Apr 26, 2022
h0tk3y added a commit that referenced this issue May 17, 2022
This should help diagnosing issues with invalid JVM installations
detections by the Java toolchains feature.

Related to #15918
@h0tk3y
Copy link
Member

h0tk3y commented May 17, 2022

The fix provides some additional information as follows:

  • An invalid JDK listed in the output of javaToolChains will now also have Caused by: lines if the failure was caused by an exception in running the java executable;
  • The --info logs will now contain the reports of failures in JVM installation discovery. Note that Gradle won't make additional attempts to run java from invalid installations during the lifetime of the Gradle daemon, for performance considerations, so one might need to restart the Gradle daemon to see the failure logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug in:toolchains Java Toolchains
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants