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

Gradle Build Does Not Work #340

Closed
schrum2 opened this issue Jan 18, 2023 · 10 comments
Closed

Gradle Build Does Not Work #340

schrum2 opened this issue Jan 18, 2023 · 10 comments

Comments

@schrum2
Copy link

schrum2 commented Jan 18, 2023

Gradle testing on a new Java codespace does not work. This failure happened in a repository where gradle previously functioned fine, so I assume that some aspect of the default codespace configuration changed. Here are some details.

Running gradle test produces this error:

Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/7.6/userguide/gradle_daemon.html
Process command line: /opt/java/11.0.14/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /usr/local/sdkman/candidates/gradle/7.6/lib/gradle-launcher-7.6.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 7.6
Please read the following process output to find out more:
-----------------------

FAILURE: Build failed with an exception.

* What went wrong:
Could not create service of type ClassLoaderRegistry using GlobalScopeServices.createClassLoaderRegistry().

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Exception is:
org.gradle.internal.service.ServiceCreationException: Could not create service of type ClassLoaderRegistry using GlobalScopeServices.createClassLoaderRegistry().
        at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:901)
        at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.createServiceInstance(DefaultServiceRegistry.java:826)
        at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectServiceProvider.getInstance(DefaultServiceRegistry.java:611)
        at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:674)
        at org.gradle.internal.service.DefaultServiceRegistry.applyConfigureMethod(DefaultServiceRegistry.java:199)
        at org.gradle.internal.service.DefaultServiceRegistry.findProviderMethods(DefaultServiceRegistry.java:181)
        at org.gradle.internal.service.DefaultServiceRegistry.addProvider(DefaultServiceRegistry.java:265)
        at org.gradle.launcher.daemon.server.DaemonServices.<init>(DaemonServices.java:86)
        at org.gradle.launcher.daemon.bootstrap.DaemonMain.doAction(DaemonMain.java:112)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:50)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
        at org.gradle.launcher.daemon.bootstrap.GradleDaemon.main(GradleDaemon.java:22)
Caused by: java.lang.IllegalArgumentException: Cannot find JAR 'jsoup-1.15.1.jar' required by module 'gradle-resources-http' using classpath or distribution directory '/usr/local/sdkman/candidates/gradle/7.6'
        at org.gradle.api.internal.classpath.DefaultModuleRegistry.findDependencyJar(DefaultModuleRegistry.java:358)
        at org.gradle.api.internal.classpath.DefaultModuleRegistry.findDependencyJars(DefaultModuleRegistry.java:220)
        at org.gradle.api.internal.classpath.DefaultModuleRegistry.module(DefaultModuleRegistry.java:210)
        at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadOptionalModule(DefaultModuleRegistry.java:190)
        at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadModule(DefaultModuleRegistry.java:174)
        at org.gradle.api.internal.classpath.DefaultModuleRegistry.getModule(DefaultModuleRegistry.java:154)
        at org.gradle.api.internal.classpath.DefaultModuleRegistry.getModules(DefaultModuleRegistry.java:228)
        at org.gradle.api.internal.classpath.DefaultModuleRegistry.access$100(DefaultModuleRegistry.java:50)
        at org.gradle.api.internal.classpath.DefaultModuleRegistry$DefaultModule.getRequiredModules(DefaultModuleRegistry.java:393)
        at org.gradle.api.internal.classpath.DefaultModuleRegistry$DefaultModule.collectRequiredModules(DefaultModuleRegistry.java:431)
        at org.gradle.api.internal.classpath.DefaultModuleRegistry$DefaultModule.getAllRequiredModules(DefaultModuleRegistry.java:414)
        at org.gradle.api.internal.DynamicModulesClassPathProvider.allRequiredModulesOf(DynamicModulesClassPathProvider.java:96)
        at org.gradle.api.internal.DynamicModulesClassPathProvider.gradleExtensionsWithout(DynamicModulesClassPathProvider.java:65)
        at org.gradle.api.internal.DynamicModulesClassPathProvider.findClassPath(DynamicModulesClassPathProvider.java:51)
        at org.gradle.api.internal.DefaultClassPathRegistry.getClassPath(DefaultClassPathRegistry.java:35)
        at org.gradle.initialization.DefaultClassLoaderRegistry.<init>(DefaultClassLoaderRegistry.java:35)
        at org.gradle.internal.service.scopes.GlobalScopeServices.createClassLoaderRegistry(GlobalScopeServices.java:296)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:125)
        at org.gradle.internal.service.ReflectionBasedServiceMethod.invoke(ReflectionBasedServiceMethod.java:34)
        at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:899)
        ... 16 more


* Get more help at https://help.gradle.org


* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Basically, it seems that gradle is looking for Java in the wrong place, but Java does run and successfully compile my code.

Here is the gradle --version:

------------------------------------------------------------
Gradle 7.6
------------------------------------------------------------

Build time:   2022-11-25 13:35:10 UTC
Revision:     daece9dbc5b79370cc8e4fd6fe4b2cd400e150a8

Kotlin:       1.7.10
Groovy:       3.0.13
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          11.0.14.1 (Microsoft 11.0.14.1+1-LTS)
OS:           Linux 5.4.0-1098-azure amd64

And the java --version:

openjdk 11.0.14.1 2022-02-08 LTS
OpenJDK Runtime Environment Microsoft-31205 (build 11.0.14.1+1-LTS)
OpenJDK 64-Bit Server VM Microsoft-31205 (build 11.0.14.1+1-LTS, mixed mode)

Also, I don't know if there is actually a connection, but I had other issues getting gradle builds to work in Java before:
https://github.com/orgs/community/discussions/37051

@samruddhikhandale
Copy link
Member

Hi 👋

Looks like a regression due to #269. According to CVE-2022-36033, jsoup jar file with version less than 1.53 contains a security vulnerability. Hence, the universal image includes a patch for it.

I had reported this issue in gradle/gradle#23316.
Looks like we'd need to wait for gradle version 8 to support this.

However, do you mind creating an issue with gradle and see if they could support jsoup@1.53 in current v7*?

In the meanwhile, you could avoid this issue by pinning to an older universal:2.1.2 image to fix this. However, your devcontainer will be at security risk due to CVE-2022-36033.

@schrum2
Copy link
Author

schrum2 commented Jan 20, 2023

I found that I could fix this with sdk uninstall gradle 7.6 followed by sdk install gradle. Does this reintroduce the security vulnerability?

@samruddhikhandale
Copy link
Member

I found that I could fix this with sdk uninstall gradle 7.6 followed by sdk install gradle. Does this reintroduce the security vulnerability?

Yep, because the jsoup jar file is installed within the gradle folder for v7.6.

@devcontainers devcontainers deleted a comment Jan 20, 2023
@samruddhikhandale
Copy link
Member

Closing as stale. Feel free to reopen the issue if needed.

@madhead
Copy link

madhead commented Feb 7, 2023

It's still an issue. GitHub support sent me here regarding this issue. Also, an issue in Gradle repo: gradle/gradle#23730

@schrum2
Copy link
Author

schrum2 commented Feb 8, 2023

Agreed. The problem still isn't fixed, so I keep working around by uninstalling/reinstalling gradle for every new codespace I make, despite the reintroduction of the security vulnerability.

Makes me wonder if the default version of gradle or some other component could be changed/lowered to avoid this. It seems odd that such a major build tool simply can't be used.

@samruddhikhandale
Copy link
Member

samruddhikhandale commented Feb 9, 2023

Apologies for the inconvenience, looks like gradle has a prerelease for 8.0 - https://github.com/gradle/gradle/releases
We can expect an official release soon, I'll ensure to quickly update the images.

In the meanwhile, can you add the following to you devcontainer.json to help you get inblocked?

"features": {
    "ghcr.io/devcontainers/features/java:1": {
        "installGradle": true
    }
}

ℹ️ This would reintroduce the security vulnerability but will help you get unblocked.

@samruddhikhandale
Copy link
Member

Planning to release this image today/tomorrow (with gradle 8) which should fix the issue/
#422

@samruddhikhandale
Copy link
Member

universal image is updated to include gradle v8.
The issue should be resolved with vulnerability patched for jsoup

@schrum2
Copy link
Author

schrum2 commented Feb 16, 2023

I just made a new codespace, and I can confirm that Gradle 8.0 was installed and the basic gradle commands worked without any problem! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@madhead @schrum2 @samruddhikhandale and others