Error creating shaded jar target\classes (Access is denied)

The error looks like this:

Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.3:shade (default) on project <project_name> 
Error creating shaded jar: <path>\target\classes (Access is denied)


Caused by: <path>\target\classes (Access is denied)
        at Method)
        at java.util.jar.JarFile.<init>(
        at java.util.jar.JarFile.<init>(
        at org.apache.maven.plugins.shade.DefaultShader.newJarFile(
        at org.apache.maven.plugins.shade.DefaultShader.shade(
        at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(
        ... 21 more

maven-shade-plugin tries to open classes folder as zip file. This happens when one of the dependencies is found on the local filesystem and not in the local maven repository. Before unpacking, the plugin should check whether target\classes is a directory or a zip file, but it doesn’t. One solution is to clean the local Maven repository from dependencies. It is located along the path:

Windows 7: C:/Documents and Settings/<username>/.m2/repository
Windows 10:C:/Users/<username>/.m2/repository
Linux: /home/<username>/.m2/repository
Mac: /Users/<username>/.m2/repository

Go to the repository folder and delete all content. After that, you need to re-import the dependencies.

Telegram channel

If you still have any questions, feel free to ask me in the comments under this article or write me at

If I saved your day, you can support me 🤝

Leave a Reply

Your email address will not be published. Required fields are marked *