5

I am getting an error intermittently when I build my Java project in Intellij.

Internal caches are corrupted or have outdated format, forcing project rebuild: java.io.FileNotFoundException: C:\target\classes\ehcache.xml (Access is denied)

I have run File->Invalidate caches. I have restarted Intellij and killed all Java processes. I eventually get it to build again but not sure what thing I try does the trick.

When I try to access the 'Target' folder, it says Access Denied.

Anyone seen this before?

TheCoder
  • 8,413
  • 15
  • 42
  • 54
  • Can you access the folder from windows explorer and create/remove files? It may have something to do with your user's rights... – Morfic Oct 20 '13 at 17:53
  • No. It says access denied. – TheCoder Oct 20 '13 at 17:57
  • I have this issue even though I have full access rights on all directories involved (it's in my home directory). I get this error even if I run IntelliJ as an administrator! I have also tried the "Invalidate caches" option with full restart, no effect. As soon as I try to compile a class, I get this exact message. The funny thing is that it does not occur if I simply rename the project folder, although nothing concerning rights changed. However, that can't possibly be the solution (especially since we depend on the directory to be named like that). – pdinklag Aug 13 '14 at 05:49

7 Answers7

4

As mentioned in my comment, I received the same message, but without any access right issues involved whatsoever.

It seemed to be some kind of confusion on IDEA's end. I was able to fix this by deleting the system directory in C:\Users\%USERNAME%\.IdeaIC13 (the path obviously depends on the IntelliJ IDEA version).

This stores all caches and indices among other things. I have to confess that I can't tell why exactly this helps, but it seems to be a rougher way to "invalidate caches" and it works. Your project history is not deleted this way, so you can practically continue working - just that all files have to be scanned again and all indices have to be rebuilt.

In any event, this was not an access rights problem at all.

pdinklag
  • 1,241
  • 1
  • 12
  • 28
  • 1
    For newer versions C:\Users\%USERNAME%\AppData\Local\JetBrains\IntelliJIdea2021.2 But didn't work for me :( – Thomas Sep 15 '21 at 14:00
1

For me, I just had to clean all modules (and ensure they didn't require sudo permission), and rebuild.

The File->Invalidate Caches/Restart... did not work for me.

Piper
  • 1,266
  • 3
  • 15
  • 26
0

If you can't access the folder have to either change the rights for the entire hierarchy starting from your project root folder as described here, or move your project to some other directory that you are allowed to access

Morfic
  • 15,178
  • 3
  • 51
  • 61
0

Tried all the above, but none worked for me. Finally running Intellij 14 in admin mode did the trick.

Uncle Iroh
  • 5,748
  • 6
  • 48
  • 61
0

I had this exact problem, I tried all of the above solutions but none of them worked for me.

The I tried the oldest one in the book (ie rebooting my laptop) and that fixed everything!

Martin Bamford
  • 379
  • 3
  • 13
0

Similar to pdinklag's answer, I had to delete my user-level Android Studio caches to get rid of this error. However, Android Studio caches are stored in ~/.android/.

I shut down Android Studio, then ran:

cd
rm .android/cache build-cache build-cache.lock

Then restarted Android Studio, and things worked.

Heath Borders
  • 30,998
  • 16
  • 147
  • 256
0

I had the same problem in Intellij 17 version for Mac. Rebuilding the project, changing the directory of the project, cleaning the module, and running IntelliJ 17 with admin mode did not work.

Updating Intellij to 2019 version solved the error. It seems the application was not able to get the admin permissions.

Pooja Ruhal
  • 5
  • 1
  • 3