- 環境
- Dockerホスト側:AWSのEC2インスタンスにあるCentOS
- Dockerコンテナ
- CentOS Linux release 7.6.1810 (Core)
- java 6
- Eclipse 2019-03
事象 : EclipseでMavenプロジェクトの更新をしたら怒られた
Failed to read artifact descriptor for jsonic:jsonic:jar:1.2.0
org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for jsonic:jsonic:jar:1.2.0
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:276)
# 省略
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact jsonic:jsonic:pom:1.2.0 from/to local (file:/home/ponsuke/path/to/../repo): /home/ponsuke/.m2/repository/jsonic/jsonic/1.2.0/jsonic-1.2.0.pom.part.lock (Permission denied)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:422)
# 省略
... 36 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact jsonic:jsonic:pom:1.2.0 from/to local (file:/home/ponsuke/path/to/../repo): /home/ponsuke/.m2/repository/jsonic/jsonic/1.2.0/jsonic-1.2.0.pom.part.lock (Permission denied)
at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:52)
# 省略
... 39 more
Caused by: java.io.FileNotFoundException: /home/ponsuke/.m2/repository/jsonic/jsonic/1.2.0/jsonic-1.2.0.pom.part.lock (Permission denied)
at java.io.RandomAccessFile.open0(Native Method)
# 省略
... 44 more
原因 : .m2
ディレクトリの持ち主が自分じゃないから
Dockerで.m2
ディレクトリを作成したので持ち主がrootさんになっている
$ sudo ls -la .m2/repository/
total 4
drwxr-xr-x. 1 root root 4096 6月 11 16:00 .
drwxr-xr-x. 1 root root 24 6月 11 16:00 ..
drwxrwxr-x. 1 root root 19 6月 11 15:38 antlr
drwxrwxr-x. 1 root root 25 6月 11 15:38 aopalliance
drwxrwxr-x. 1 root root 39 6月 11 15:38 args4j
drwxrwxr-x. 1 root root 70 6月 11 15:38 asm
# 省略
対応方法 : 持ち主を自分に変更する
1.. 持ち主を自分に変更する
$ sudo chown -R ponsuke .m2/
$ sudo ls -la .m2/repository/
total 4
drwxr-xr-x. 1 ponsuke root 4096 6月 11 16:00 .
drwxr-xr-x. 1 ponsuke root 24 6月 11 16:00 ..
drwxrwxr-x. 1 ponsuke root 19 6月 11 15:38 antlr
drwxrwxr-x. 1 ponsuke root 25 6月 11 15:38 aopalliance
drwxrwxr-x. 1 ponsuke root 39 6月 11 15:38 args4j
drwxrwxr-x. 1 ponsuke root 70 6月 11 15:38 asm
# 省略
2..再びEclipseでMavenプロジェクトの更新をする