File created during maven build can’t be copied

javapermission

Hardware:
MacBook Pro (Retina, 15-inch, Mid 2015)\
OS:
OS X El Capitan, 10.11.6

Problem:
I have a standard maven project which I build using mvn clean install from the command line. I receive an error on the install process which says Permission Denied for the created jar file so it can't copy it over.

Looking in the directory I see:

$ cd target/
$ ls -al
total 230856
drwxr-xr-x  10 u1  g1        340 Dec 21 16:08 ./
drwxr-xr-x  12 u1  g1        408 Dec 21 16:08 ../
drwxr-xr-x   5 u1  g1        170 Dec 21 16:08 classes/
drwxr-xr-x   4 u1  g1        136 Dec 21 16:08 generated-sources/
drwxr-xr-x   3 u1  g1        102 Dec 21 16:08 jcasgen/
drwxr-xr-x   3 u1  g1        102 Dec 21 16:08 maven-archiver/
drwxr-xr-x   3 u1  g1        102 Dec 21 16:08 maven-status/
-rw-r--r--   1 u1  g1      38239 Dec 21 16:08 rules-0.0.1-SNAPSHOT-sources.jar
-rw-r--r--   1 u1  g1  118102157 Dec 21 16:08 rules-0.0.1-SNAPSHOT.jar
-rw-r--r--   1 u1  g1      53247 Dec 21 16:08 original-rules-0.0.1-SNAPSHOT.jar

If I do an ls -le I don't see any extended ACLs. If I try to copy the large JAR file:

$ cp rules-0.0.1-SNAPSHOT.jar ~
cp: rules-0.0.1-SNAPSHOT.jar: Permission denied
$ sudo cp rules-0.0.1-SNAPSHOT.jar ~
Password:
cp: rules-0.0.1-SNAPSHOT.jar: Permission denied
$ cp rules-0.0.1-SNAPSHOT-sources.jar ~
$ 

It's just that single file that won't copy. I have discovered that I can mv the file other places, but copying just doesn't work no matter where I put it.

What else is interesting is that I can move my code anywhere in the file system, rerun the build, and that single created file has the same issue.

I have booted to the recovery console and reset the ACLs and permissions for my home directory to no effect. I have run Disk Utility and it shows everything to be okay.

Has anyone seen anything like this before? Other Mac folks here are saying I'll need to boot single user and fsck -y the drive.

Additional Info

By default, the maven install step uses the maven-shade-plugin to build an uber-jar. It is this uber-jar that cannot be copied. If I disable the maven-shade-plugin, so that the final JAR is a normal jar, I don't see the problem.

I have Trend Micro running on my Mac if that could make a difference.

I have discovered that if I overwrite the uber-jar with different data (same name) the file become copyable. For example:

cat > rules-0.0.1-SHAPSHOT.jar
asdf
^D

After that, I can copy the file.

I have tried to watch things with opensnoop but all I see is a "Permission Denied" on an open by java.

Best Answer

Although this is an unsatisfying answer, updating to the latest version of the maven-shade-plugin "fixed" the problem.