2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Dockerで作った環境のMavenで/home/path/.m2/repository/x.pom.part.lock (Permission denied)となった時の対応方法

Last updated at Posted at 2019-06-12
  • 環境
    • 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プロジェクトの更新をする

ほかの原因

プロジェクトをMavenでビルドできない時の対応方法 - Qiita

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?