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 + quarkus-container-image-jib: AccessDeniedException on second run on Windows #11900

Closed
andreas-eberle opened this issue Sep 4, 2020 · 10 comments · Fixed by #11922
Closed
Assignees
Labels
area/container-image area/gradle Gradle env/windows Impacts Windows machines kind/bug Something isn't working triage/wontfix This will not be worked on

Comments

@andreas-eberle
Copy link
Contributor

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
@quarkusbot
Copy link

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

@geoand
Copy link
Contributor

geoand commented Sep 5, 2020

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

@geoand
Copy link
Contributor

geoand commented Sep 5, 2020

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...

geoand added a commit to geoand/quarkus that referenced this issue Sep 5, 2020
In Windows it seems like AccessDeniedException can be thrown
when a directory is deleted and then immediately recreated.
The problem can be mitigated by retrying the operation as
is mentioned in https://bugs.openjdk.java.net/browse/JDK-8029608

Fixes: quarkusio#11900
@geoand
Copy link
Contributor

geoand commented Sep 5, 2020

Would you be willing to give #11922 a try and see if it fixes your issue?

@geoand geoand self-assigned this Sep 5, 2020
geoand added a commit that referenced this issue Sep 7, 2020
Attempt to get around AccessDeniedException in Windows
@andreas-eberle
Copy link
Contributor Author

andreas-eberle commented Sep 7, 2020

@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.

@geoand
Copy link
Contributor

geoand commented Sep 7, 2020

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

@geoand geoand reopened this Sep 7, 2020
@glefloch
Copy link
Member

glefloch commented Sep 7, 2020

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

@gsmet gsmet added this to the 1.8.0.Final milestone Sep 8, 2020
gsmet pushed a commit to gsmet/quarkus that referenced this issue Sep 8, 2020
In Windows it seems like AccessDeniedException can be thrown
when a directory is deleted and then immediately recreated.
The problem can be mitigated by retrying the operation as
is mentioned in https://bugs.openjdk.java.net/browse/JDK-8029608

Fixes: quarkusio#11900
@gsmet gsmet modified the milestones: 1.8.0.Final, 1.7.3.Final Sep 8, 2020
gsmet pushed a commit to gsmet/quarkus that referenced this issue Sep 8, 2020
In Windows it seems like AccessDeniedException can be thrown
when a directory is deleted and then immediately recreated.
The problem can be mitigated by retrying the operation as
is mentioned in https://bugs.openjdk.java.net/browse/JDK-8029608

Fixes: quarkusio#11900
@glefloch
Copy link
Member

glefloch commented Sep 8, 2020

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 (gradle/gradle#937) ...

@geoand
Copy link
Contributor

geoand commented Sep 8, 2020

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

@glefloch
Copy link
Member

glefloch commented Sep 8, 2020

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

@geoand geoand closed this as completed Sep 8, 2020
@geoand geoand removed this from the 1.7.3.Final milestone Sep 8, 2020
@geoand geoand added the triage/wontfix This will not be worked on label Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/container-image area/gradle Gradle env/windows Impacts Windows machines kind/bug Something isn't working triage/wontfix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants