I occasionally receive this error when I build my project with
>mvn --version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602
In my case the parent directory inside which maven was trying to create a directory was root, so I did a sudo chown -R : /path/to/directory to change permissions before rerunning the mvn command.
You can use the following in pom.xml
<build>
<directory>${project.basedir}/target1</directory>
</build>
In my case, I opened the jar in 7zip and I opened the target folder. I run my application and received this error. After closing 7zip, the application run fine and build successfully.