Quarkus: Gradle + quarkus-container-image-jib: AccessDeniedException on second run on Windows

Created on 4 Sep 2020  路  10Comments  路  Source: quarkusio/quarkus

Describe the bug
I try to build a container image with the quarkus-container-image-jib extension in my Quarkus (gradle, Kotlin) project on my Windows 10 PC. The first run works (./gradlew assemble -Dquarkus.container-image.build=true). On the second and any further runs l I always get AccessDeniedExceptions. When I stop the gradle deamons (./gradlew --stop) or kill them via the TaskManager, it works again for one run but then I end up with the same issue.

Full exception:

17:15:27: Executing task 'assemble -Dquarkus.container-image.build=true'...


> Task :quarkusGenerateCode
preparing quarkus application
kotlin scripting plugin: root project 'code-with-quarkus'.compileQuarkus-generated-sourcesKotlin - configuration not found: quarkus-generated-sourcesKotlinScriptDef, the plugin is probably applied by a mistake

> Task :quarkusGenerateCodeTests
preparing quarkus application
kotlin scripting plugin: root project 'code-with-quarkus'.compileQuarkus-test-generated-sourcesKotlin - configuration not found: quarkus-test-generated-sourcesKotlinScriptDef, the plugin is probably applied by a mistake

> Task :compileKotlin
> Task :compileJava NO-SOURCE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :inspectClassesForKotlinIC
> Task :jar

> Task :quarkusBuild FAILED
building quarkus jar
7 actionable tasks: 6 executed, 1 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':quarkusBuild'.
> io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkus.deployment.pkg.steps.JarResultBuildStep#buildRunnerJar threw an exception: java.lang.IllegalStateException: java.nio.file.AccessDeniedException: C:\development\quarkus-debugging\bug-reports\2020-09-04_jib-problems\build\lib
    at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:941)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
    at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
    at java.base/java.lang.Thread.run(Thread.java:830)
    at org.jboss.threads.JBossThread.run(JBossThread.java:479)
  Caused by: java.nio.file.AccessDeniedException: C:\development\quarkus-debugging\bug-reports\2020-09-04_jib-problems\build\lib
    at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89)
    at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
    at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
    at java.base/sun.nio.fs.WindowsFileSystemProvider.createDirectory(WindowsFileSystemProvider.java:506)
    at java.base/java.nio.file.Files.createDirectory(Files.java:693)
    at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:800)
    at java.base/java.nio.file.Files.createDirectories(Files.java:786)
    at io.quarkus.deployment.pkg.steps.JarResultBuildStep.buildLegacyThinJar(JarResultBuildStep.java:418)
    at io.quarkus.deployment.pkg.steps.JarResultBuildStep.buildRunnerJar(JarResultBuildStep.java:192)
    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:567)
    at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:932)
    ... 7 more


* 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

BUILD FAILED in 4s
17:15:32: Task execution finished 'assemble -Dquarkus.container-image.build=true'.

To Reproduce
Steps to reproduce the behavior:

  1. I assume you need a Windows machine (I have Windows 10)
  2. Download reproducer project and unzip it
    2020-09-04_jib-problems.zip
  3. Run ./gradlew assemble -Dquarkus.container-image.build=true
  4. Change something in the code (e.g. in ExampleResource)
  5. Run ./gradlew assemble -Dquarkus.container-image.build=true again (now it should crash with the AccessDeniedException)

Environment (please complete the following information):

  • Windows 10

    • Gradle

    • Kotlin

    • OpenJDK 11

arecontainer-image aregradle enwindows kinbug triagwontfix

Most helpful comment

@geoand I will access to a windows machine tonight. I will give a try to those two issues.

All 10 comments

/cc @geoand
/cc @quarkusio/devtools, @glefloch

This is really weird indeed... Unfortunately I don't have a Windows machine so I can't reproduce it

This seems to be a Windows problem... See: https://bugs.openjdk.java.net/browse/JDK-8029608

The only way I see around it is for us to sleep and re-attempt creating the directory when this happens...

Would you be willing to give https://github.com/quarkusio/quarkus/pull/11922 a try and see if it fixes your issue?

@geoand: Unfortunately, this does not seem to fix the issue. I still get the same error. Furthermore, I don't think this is a timing issue only, since I can only fix it by stopping the gradle deamons. Therefore it looks to me like the gradle deamons seem to keep some file lock on the directories or something like that.

Please reopen this issue.

I see. I'll reopen the issue then and ask @glefloch if he has any ideas

@geoand I will access to a windows machine tonight. I will give a try to those two issues.

I can reproduce the error. I tried using the latest version of gradle but I still have the issue.
As you said @andreas-eberle I think the problem is related to the gradle dameon, running the assemble commande multiple time with--no-daemon actually works.
Even after a long time, I can't do a ./gradlew clean as the build directory seems to be locked.

This looks like a known issue (https://github.com/gradle/gradle/issues/937) ...

So I guess we should close this as it's not a Quarkus issue?

Well I don't think we can do much more in Quarkus

Was this page helpful?
0 / 5 - 0 ratings