Getting AccessDeniedException when cloning repo in Java using JGit

1.3k views Asked by At

I am programmatically trying to clone a repo using the JGit API. I am using the following piece of code, but when I execute it, I am getting an error.

I have tried all possible solutions which I could find but still I am unable to resolve the problem. Can anyone provide inputs?

File localPath = File.createTempFile("TestGitRepository", "");
Git result = Git.cloneRepository()
                .setURI("https://gitlab.wuintranet.net/fe/wu-content.git")
                .setDirectory(localPath)
                .call(); 

The repo at "https://gitlab.wuintranet.net/fe/wu-content.git" should get cloned but it is throwing this error:

java.nio.file.AccessDeniedException: C:\Program Files\Git\mingw64\etc.probe-e65aa729-82b1-4ff9-8d9b-3a4a7ea3de4a
2

There are 2 answers

0
NotMyFaultSir On

I got the same problem under windows during gradle tests. Running the console to from which i start the test in admin mode worked for me. On other operating systems running it with sudo might work.

0
ozkanpakdil On

It looks like a bug they found in last version."5.3.1.201904271842-r" is working for me. you can go back. here is the details

https://github.com/diffplug/spotless/issues/410